Project import generated by Copybara.

GitOrigin-RevId: 24b4df7b97acabc86a9d964ddde00bb4ebf9eaff
This commit is contained in:
Madari Developers 2025-01-03 18:43:50 +00:00
parent e13ae831fd
commit 4d1adb5299
4 changed files with 79 additions and 87 deletions

View file

@ -172,4 +172,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: macos-build
path: build/macos/Build/Products/Release/Madari.app
path: build/macos/Build/Products/Release

View file

@ -21,7 +21,9 @@ class AppDatabase extends _$AppDatabase {
name: 'madari_db',
web: DriftWebOptions(
sqlite3Wasm: Uri.parse('sqlite3.wasm'),
driftWorker: Uri.parse('assets/assets/drift_worker.dart.js'),
driftWorker: Uri.parse(
'assets/assets/ignore_this_error_drift_worker.dart.js',
),
),
);
}

View file

@ -194,74 +194,78 @@ class StremioConnectionService extends BaseConnectionService {
continue;
}
final url =
"${_getAddonBaseURL(addon)}/stream/${meta.type}/${Uri.encodeComponent(id.id)}.json";
try {
final url =
"${_getAddonBaseURL(addon)}/stream/${meta.type}/${Uri.encodeComponent(id.id)}.json";
final result = await http.get(Uri.parse(url), headers: {});
final result = await http.get(Uri.parse(url), headers: {});
if (result.statusCode == 404) {
if (result.statusCode == 404) {
continue;
}
final body = StreamResponse.fromJson(jsonDecode(result.body));
streams.addAll(
body.streams
.map((item) {
String streamTitle = item.title ?? item.name ?? "No title";
try {
streamTitle = utf8.decode(
(item.title ?? item.name ?? "No Title").runes.toList(),
);
} catch (e) {}
final streamDescription = item.description != null
? utf8.decode(
(item.description!).runes.toList(),
)
: null;
String title = meta.name ?? item.title ?? "No title";
if (season != null) title += " S$season";
if (episode != null) title += " E$episode";
DocSource? source;
if (item.url != null) {
source = MediaURLSource(
title: title,
url: item.url!,
id: meta.id,
);
}
if (item.infoHash != null) {
source = TorrentSource(
title: title,
infoHash: item.infoHash!,
id: meta.id,
fileName: "$title.mp4",
season: season,
episode: episode,
);
}
if (source == null) {
return null;
}
return StreamList(
title: streamTitle,
description: streamDescription,
source: source,
);
})
.whereType<StreamList>()
.toList(),
);
} catch (e) {
continue;
}
final body = StreamResponse.fromJson(jsonDecode(result.body));
streams.addAll(
body.streams
.map((item) {
String streamTitle = item.title ?? item.name ?? "No title";
try {
streamTitle = utf8.decode(
(item.title ?? item.name ?? "No Title").runes.toList(),
);
} catch (e) {}
final streamDescription = item.description != null
? utf8.decode(
(item.description!).runes.toList(),
)
: null;
String title = meta.name ?? item.title ?? "No title";
if (season != null) title += " S$season";
if (episode != null) title += " E$episode";
DocSource? source;
if (item.url != null) {
source = MediaURLSource(
title: title,
url: item.url!,
id: meta.id,
);
}
if (item.infoHash != null) {
source = TorrentSource(
title: title,
infoHash: item.infoHash!,
id: meta.id,
fileName: "$title.mp4",
season: season,
episode: episode,
);
}
if (source == null) {
return null;
}
return StreamList(
title: streamTitle,
description: streamDescription,
source: source,
);
})
.whereType<StreamList>()
.toList(),
);
if (streams.isNotEmpty) yield streams;
}
}

View file

@ -7,7 +7,6 @@ import 'package:madari_client/pages/stremio_item.page.dart';
import 'features/connections/types/stremio/stremio_base.types.dart';
import 'pages/download.page.dart';
import 'pages/getting_started.page.dart';
import 'pages/home.page.dart';
import 'pages/home_tab.page.dart';
import 'pages/more_tab.page.dart';
@ -108,15 +107,6 @@ GoRouter createRouter() {
return Container();
},
),
ShellRoute(
parentNavigatorKey: rootNavigatorKey,
routes: [
GoRoute(
path: GettingStartedPage.routeName,
builder: (context, state) => const GettingStartedPage(),
),
],
),
GoRoute(
path: SignInPage.routeName,
builder: (context, state) => const SignInPage(),
@ -129,23 +119,19 @@ GoRouter createRouter() {
);
}
String? _routeGuard(
BuildContext context,
GoRouterState state,
) {
String? _routeGuard(BuildContext context, GoRouterState state) {
final isLoggedIn = AppEngine.engine.pb.authStore.isValid;
final bool isLoggingIn = state.uri.toString() == SignInPage.routeName ||
state.uri.toString() == GettingStartedPage.routeName ||
state.uri.toString() == SignUpPage.routeName;
final publicRoutes = [
SignInPage.routeName,
SignUpPage.routeName,
];
if (!isLoggedIn && !isLoggingIn) {
return AppEngine.engine.pb.authStore.record?.getStringValue("setup") == ""
? GettingStartedPage.routeName
: SignInPage.routeName;
if (!isLoggedIn && !publicRoutes.contains(state.uri.path)) {
return SignInPage.routeName;
}
if (isLoggedIn && isLoggingIn) {
if (isLoggedIn && publicRoutes.contains(state.uri.path)) {
return '/';
}