mirror of
https://github.com/madari-media/madari-oss.git
synced 2026-04-21 06:51:56 +00:00
Project import generated by Copybara.
Some checks are pending
Build and Deploy / build_windows (push) Waiting to run
Build and Deploy / build_android (push) Waiting to run
Build and Deploy / build_ipa (push) Waiting to run
Build and Deploy / build_linux (push) Waiting to run
Build and Deploy / build_macos (push) Waiting to run
Some checks are pending
Build and Deploy / build_windows (push) Waiting to run
Build and Deploy / build_android (push) Waiting to run
Build and Deploy / build_ipa (push) Waiting to run
Build and Deploy / build_linux (push) Waiting to run
Build and Deploy / build_macos (push) Waiting to run
GitOrigin-RevId: bb822a1f9b49fb2aa3fdb9e0c91b6d9d9f1c11a5
This commit is contained in:
parent
c8e23fa02f
commit
b816d78d98
4 changed files with 73 additions and 0 deletions
|
|
@ -69,6 +69,24 @@ class _VideoViewerState extends State<VideoViewer> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (widget.meta is types.Meta) {
|
||||||
|
try {
|
||||||
|
if (player.state.playing) {
|
||||||
|
TraktService.instance!.startScrobbling(
|
||||||
|
meta: widget.meta as types.Meta,
|
||||||
|
progress: progress.toDouble(),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
TraktService.instance!.stopScrobbling(
|
||||||
|
meta: widget.meta as types.Meta,
|
||||||
|
progress: progress.toDouble(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
print(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
zeeeWatchHistory!.saveWatchHistory(
|
zeeeWatchHistory!.saveWatchHistory(
|
||||||
history: WatchHistory(
|
history: WatchHistory(
|
||||||
id: _source.id,
|
id: _source.id,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:madari_client/engine/engine.dart';
|
import 'package:madari_client/engine/engine.dart';
|
||||||
|
import 'package:madari_client/features/trakt/service/trakt.service.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
import '../../../utils/auth_refresh.dart';
|
import '../../../utils/auth_refresh.dart';
|
||||||
|
|
@ -189,6 +190,30 @@ class _TraktIntegrationState extends State<TraktIntegration> {
|
||||||
),
|
),
|
||||||
centerTitle: true,
|
centerTitle: true,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
|
actions: [
|
||||||
|
TextButton(
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).push(
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text("Logs"),
|
||||||
|
),
|
||||||
|
body: ListView.builder(
|
||||||
|
itemCount: TraktService.instance!.debugLogs.length,
|
||||||
|
itemBuilder: (context, item) {
|
||||||
|
return Text(
|
||||||
|
TraktService.instance!.debugLogs[item],
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Text("Debug logs"),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@ class TraktService {
|
||||||
final Map<String, dynamic> _cache = {};
|
final Map<String, dynamic> _cache = {};
|
||||||
Timer? _cacheRevalidationTimer;
|
Timer? _cacheRevalidationTimer;
|
||||||
|
|
||||||
|
clearCache() {
|
||||||
|
_cache.clear();
|
||||||
|
}
|
||||||
|
|
||||||
static ensureInitialized() async {
|
static ensureInitialized() async {
|
||||||
if (_instance != null) {
|
if (_instance != null) {
|
||||||
return _instance;
|
return _instance;
|
||||||
|
|
@ -90,6 +94,8 @@ class TraktService {
|
||||||
return AppEngine.engine.pb.authStore.record!.getStringValue("trakt_token");
|
return AppEngine.engine.pb.authStore.record!.getStringValue("trakt_token");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<String> debugLogs = [];
|
||||||
|
|
||||||
Map<String, String> get headers => {
|
Map<String, String> get headers => {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
'Accept-Content': 'application/json',
|
'Accept-Content': 'application/json',
|
||||||
|
|
@ -108,11 +114,13 @@ class TraktService {
|
||||||
|
|
||||||
if (method == 'GET') {
|
if (method == 'GET') {
|
||||||
if (_getRequestCount >= _authedGetLimit) {
|
if (_getRequestCount >= _authedGetLimit) {
|
||||||
|
debugLogs.add("GET rate limit exceeded");
|
||||||
throw Exception('GET rate limit exceeded');
|
throw Exception('GET rate limit exceeded');
|
||||||
}
|
}
|
||||||
_getRequestCount++;
|
_getRequestCount++;
|
||||||
} else if (method == 'POST' || method == 'PUT' || method == 'DELETE') {
|
} else if (method == 'POST' || method == 'PUT' || method == 'DELETE') {
|
||||||
if (_postRequestCount >= _authedPostLimit) {
|
if (_postRequestCount >= _authedPostLimit) {
|
||||||
|
debugLogs.add("GET rate limit exceeded");
|
||||||
throw Exception('POST/PUT/DELETE rate limit exceeded');
|
throw Exception('POST/PUT/DELETE rate limit exceeded');
|
||||||
}
|
}
|
||||||
_postRequestCount++;
|
_postRequestCount++;
|
||||||
|
|
@ -148,9 +156,15 @@ class TraktService {
|
||||||
final response = await http.get(Uri.parse(url), headers: headers);
|
final response = await http.get(Uri.parse(url), headers: headers);
|
||||||
|
|
||||||
if (response.statusCode != 200) {
|
if (response.statusCode != 200) {
|
||||||
|
debugLogs.add(
|
||||||
|
"Failed to fetch data from ${url.replaceFirst("https://api.trakt.tv/", "")} ${response.statusCode}");
|
||||||
throw Exception('Failed to fetch data from $url');
|
throw Exception('Failed to fetch data from $url');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugLogs.add(
|
||||||
|
"Success calling api ${url.replaceFirst("https://api.trakt.tv/", "")}",
|
||||||
|
);
|
||||||
|
|
||||||
final data = json.decode(response.body);
|
final data = json.decode(response.body);
|
||||||
_cache[url] = data;
|
_cache[url] = data;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
|
import 'package:cached_query/cached_query.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import 'package:madari_client/engine/engine.dart';
|
import 'package:madari_client/engine/engine.dart';
|
||||||
import 'package:madari_client/features/settings/screen/trakt_integration_screen.dart';
|
import 'package:madari_client/features/settings/screen/trakt_integration_screen.dart';
|
||||||
|
import 'package:madari_client/features/trakt/service/trakt.service.dart';
|
||||||
import 'package:madari_client/features/watch_history/service/zeee_watch_history.dart';
|
import 'package:madari_client/features/watch_history/service/zeee_watch_history.dart';
|
||||||
import 'package:madari_client/pages/sign_in.page.dart';
|
import 'package:madari_client/pages/sign_in.page.dart';
|
||||||
|
|
||||||
|
|
@ -74,6 +76,20 @@ class MoreContainer extends StatelessWidget {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
ListTile(
|
||||||
|
leading: const Icon(Icons.clear_all),
|
||||||
|
title: const Text("Clear Cache"),
|
||||||
|
onTap: () {
|
||||||
|
TraktService.instance?.clearCache();
|
||||||
|
CachedQuery.instance.deleteCache();
|
||||||
|
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text("Cache cleared"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
_buildListItem(
|
_buildListItem(
|
||||||
context,
|
context,
|
||||||
icon: Icons.logout,
|
icon: Icons.logout,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue