Add id_from_url function
MODIFY
plextraktsync/commands/inspect.py
plextraktsync/commands/inspect.py
from plextraktsync.factory import factory
from plextraktsync.version import version
+from urllib.parse import urlparse, parse_qs
def print_watched_shows():
@@ -80,6 +81,21 @@ def inspect_media(id):
print(f"- {h.viewedAt} by {h.account.name} on {h.device.name} with {h.device.platform}")
+def id_from_url(url: str):
+ """
+ Extracts id from urls like:
+ https://app.plex.tv/desktop/#!/server/abcdefg/details?key=%2Flibrary%2Fmetadata%2F13202
+ """
+ result = urlparse(url)
+ if result.fragment[0] == '!':
+ parsed = parse_qs(urlparse(result.fragment).query)
+ key = ','.join(parsed['key'])
+ if key.startswith('/library/metadata/'):
+ return int(key[len('/library/metadata/'):])
+
+ return url
+
+
def inspect(input, watched_shows: bool):
print(f"PlexTraktSync [{version()}]")

Add id_from_url function