Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing single character variables conflicting with debug commands. #5

Merged
merged 2 commits into from
Aug 31, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,36 @@ def migrate(plex_url: str, plex_token: str, jellyfin_url: str,
jf_uid = jellyfin.get_user_id(name=jellyfin_user)
jf_library = jellyfin.get_all(user_id=jf_uid)

for w in plex_watched:
search_result = _search(jf_library, w)
for watched in plex_watched:
search_result = _search(jf_library, watched)
if search_result and not search_result['UserData']['Played']:
jellyfin.mark_watched(
user_id=jf_uid, item_id=search_result['Id'])
print(f"{bcolors.OKGREEN}Marked {w['title']} as watched{bcolors.ENDC}")
print(f"{bcolors.OKGREEN}Marked {watched['title']} as watched{bcolors.ENDC}")
elif not search_result:
print(f"{bcolors.WARNING}No matches for {w['title']}{bcolors.ENDC}")
print(f"{bcolors.WARNING}No matches for {watched['title']}{bcolors.ENDC}")
if not skip:
sys.exit(1)
else:
if debug:
print(f"{bcolors.OKBLUE}{w['title']}{bcolors.ENDC}")
print(f"{bcolors.OKBLUE}{watched['title']}{bcolors.ENDC}")

print(f"{bcolors.OKGREEN}Succesfully migrated {len(plex_watched)} items{bcolors.ENDC}")


def _search(data: dict, item: dict) -> List:
def _search(lib_data: dict, item: dict) -> List:
ankenyr marked this conversation as resolved.
Show resolved Hide resolved
"""Search for plex item in jellyfin library

Args:
data (dict): jellyfin lib as returned by client
lib_data (dict): jellyfin lib as returned by client
item (dict): Plex item

Returns:
List: [description]
"""
for d in data:
if d['ProviderIds'].get(item['provider']) == item['item_id']:
return d
for data in lib_data:
if data['ProviderIds'].get(item['provider']) == item['item_id']:
return data


def _extract_provider(data: dict) -> dict:
Expand Down