-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tautulli): add ability to open media in Plex
- Loading branch information
1 parent
47ff262
commit 5cf1a06
Showing
11 changed files
with
149 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
lib/modules/tautulli/routes/media_details/widgets/open_plex_button.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:lunasea/core.dart'; | ||
import 'package:lunasea/extensions/string/links.dart'; | ||
import 'package:lunasea/modules/tautulli.dart'; | ||
import 'package:lunasea/utils/links.dart'; | ||
|
||
class TautulliMediaDetailsOpenPlexButton extends StatelessWidget { | ||
final TautulliMediaType mediaType; | ||
final int ratingKey; | ||
|
||
const TautulliMediaDetailsOpenPlexButton({ | ||
Key? key, | ||
required this.mediaType, | ||
required this.ratingKey, | ||
}) : super(key: key); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return FutureBuilder( | ||
future: context.watch<TautulliState>().serverIdentity, | ||
builder: (context, snapshot) { | ||
if (_isValidMediaType() && snapshot.hasData) { | ||
return LunaIconButton.appBar( | ||
icon: LunaIcons.PLEX, | ||
onPressed: () => _openPlex(snapshot.data as TautulliServerIdentity), | ||
); | ||
} | ||
return const SizedBox(); | ||
}, | ||
); | ||
} | ||
|
||
bool _isValidMediaType() { | ||
const invalidTypes = [ | ||
TautulliMediaType.TRACK, | ||
TautulliMediaType.PHOTO, | ||
]; | ||
return !invalidTypes.contains(mediaType); | ||
} | ||
|
||
Future<void> _openPlex(TautulliServerIdentity identity) async { | ||
final mobile = LunaLinkedContent.plexMobile( | ||
identity.machineIdentifier!, | ||
ratingKey, | ||
); | ||
|
||
if (await mobile.canOpenUrl()) { | ||
mobile.openLink(); | ||
return; | ||
} | ||
|
||
final web = LunaLinkedContent.plexWeb( | ||
identity.machineIdentifier!, | ||
ratingKey, | ||
mediaType == TautulliMediaType.CLIP, | ||
); | ||
web.openLink(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters