mirror of
https://github.com/madari-media/madari-oss.git
synced 2026-04-20 01:42:03 +00:00
Project import generated by Copybara.
GitOrigin-RevId: 1b464e4e484bda49fb982d814d45f6568db99de7
This commit is contained in:
parent
47da5ffc74
commit
c8e23fa02f
5 changed files with 67 additions and 17 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:cached_query/cached_query.dart';
|
||||
|
|
@ -37,7 +38,7 @@ class StremioConnectionService extends BaseConnectionService {
|
|||
refetchDuration: (id as Meta).type == "movie"
|
||||
? const Duration(days: 30)
|
||||
: const Duration(
|
||||
minutes: 10,
|
||||
days: 1,
|
||||
),
|
||||
),
|
||||
queryFn: () async {
|
||||
|
|
@ -78,8 +79,13 @@ class StremioConnectionService extends BaseConnectionService {
|
|||
),
|
||||
);
|
||||
|
||||
return StreamMetaResponse.fromJson(jsonDecode(result.body))
|
||||
.meta;
|
||||
final item = jsonDecode(result.body);
|
||||
|
||||
if (item['meta'] == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return StreamMetaResponse.fromJson(item).meta;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
@ -211,12 +217,20 @@ class StremioConnectionService extends BaseConnectionService {
|
|||
ids.map(
|
||||
(res) async {
|
||||
return getItemById(res).then((item) {
|
||||
if (item == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (item as Meta).copyWith(
|
||||
progress: (res as Meta).progress,
|
||||
nextSeason: res.nextSeason,
|
||||
nextEpisode: res.nextEpisode,
|
||||
nextEpisodeTitle: res.nextEpisodeTitle,
|
||||
);
|
||||
}).catchError((err, stack) {
|
||||
print(err);
|
||||
print(stack);
|
||||
return null;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
|
|
|||
|
|
@ -316,6 +316,8 @@ class Meta extends LibraryItem {
|
|||
|
||||
final dynamic externalIds;
|
||||
|
||||
bool forceRegularMode;
|
||||
|
||||
String get imdbRating {
|
||||
return (imdbRating_ ?? "").toString();
|
||||
}
|
||||
|
|
@ -344,6 +346,7 @@ class Meta extends LibraryItem {
|
|||
this.cast,
|
||||
this.traktId,
|
||||
this.country,
|
||||
this.forceRegularMode = false,
|
||||
this.externalIds,
|
||||
this.description,
|
||||
this.genre,
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class StremioCard extends StatelessWidget {
|
|||
},
|
||||
);
|
||||
},
|
||||
child: meta.nextSeason == null || meta.progress != null
|
||||
child: (meta.nextSeason == null || meta.progress != null)
|
||||
? _buildRegular(context, meta)
|
||||
: _buildWideCard(context, meta),
|
||||
),
|
||||
|
|
@ -69,7 +69,9 @@ class StremioCard extends StatelessWidget {
|
|||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: CachedNetworkImageProvider(
|
||||
"https://proxy-image.syncws.com/insecure/plain/${Uri.encodeQueryComponent(meta.background!)}@webp",
|
||||
"https://proxy-image.syncws.com/insecure/plain/${Uri.encodeQueryComponent(
|
||||
meta.currentVideo?.thumbnail ?? meta.background!,
|
||||
)}@webp",
|
||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||
),
|
||||
fit: BoxFit.cover,
|
||||
|
|
@ -248,7 +250,8 @@ class StremioCard extends StatelessWidget {
|
|||
}
|
||||
|
||||
_buildRegular(BuildContext context, Meta meta) {
|
||||
final backgroundImage = getBackgroundImage(meta);
|
||||
final backgroundImage =
|
||||
meta.poster ?? meta.logo ?? getBackgroundImage(meta);
|
||||
|
||||
return Hero(
|
||||
tag: "$prefix${meta.type}${item.id}",
|
||||
|
|
@ -267,16 +270,18 @@ class StremioCard extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
Container(
|
||||
color: Colors.white,
|
||||
color: Colors.grey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(
|
||||
meta.name ?? "No name",
|
||||
meta.name ?? "No title",
|
||||
style:
|
||||
Theme.of(context).textTheme.labelMedium?.copyWith(
|
||||
color: Colors.black54,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:madari_client/features/connections/service/base_connection_service.dart';
|
||||
import 'package:madari_client/features/trakt/service/trakt.service.dart';
|
||||
|
|
@ -23,11 +25,26 @@ class TraktContainerState extends State<TraktContainer> {
|
|||
bool _isLoading = false;
|
||||
String? _error;
|
||||
|
||||
late Timer _timer;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_cacheService = TraktCacheService();
|
||||
_loadData();
|
||||
|
||||
_timer = Timer.periodic(
|
||||
const Duration(seconds: 30),
|
||||
(timer) {
|
||||
_loadData();
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_timer.cancel();
|
||||
}
|
||||
|
||||
Future<void> _loadData() async {
|
||||
|
|
@ -38,15 +55,19 @@ class TraktContainerState extends State<TraktContainer> {
|
|||
|
||||
try {
|
||||
final items = await _cacheService.fetchData(widget.loadId);
|
||||
setState(() {
|
||||
_cachedItems = items;
|
||||
_isLoading = false;
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_cachedItems = items;
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
setState(() {
|
||||
_error = e.toString();
|
||||
_isLoading = false;
|
||||
});
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_error = e.toString();
|
||||
_isLoading = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -257,7 +257,6 @@ class TraktService {
|
|||
|
||||
final result = await stremioService!.getBulkItem(
|
||||
continueWatching
|
||||
.sublist(0, 20)
|
||||
.map((movie) {
|
||||
try {
|
||||
if (movie['type'] == 'episode') {
|
||||
|
|
@ -364,6 +363,14 @@ class TraktService {
|
|||
try {
|
||||
final type = item['type'];
|
||||
final imdb = item[type]['ids']['imdb'];
|
||||
|
||||
if (type == "show") {
|
||||
return Meta(
|
||||
type: "series",
|
||||
id: imdb,
|
||||
);
|
||||
}
|
||||
|
||||
return Meta(
|
||||
type: type,
|
||||
id: imdb,
|
||||
|
|
|
|||
Loading…
Reference in a new issue