Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

fix(dashboard): fix issue where local items could prevent ui cache from completing #341

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
70 changes: 34 additions & 36 deletions Contents/Code/webapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,10 @@
og_db = database
og_db_id = database_id

try:
year = item.year
except AttributeError:
year = None
year = getattr(item, 'year', None)

# convert imdb id to tmdb id, so we can build the issue url properly
if item.type == 'movie' and (
if item.type == 'movie' and database_id and (
item_agent == 'com.plexapp.agents.imdb'
or database_id.startswith('tt')
):
Expand All @@ -276,56 +273,57 @@

item_issue_url = None

try:
issue_url = issue_urls[database_type]
except KeyError:
issue_url = None
issue_url = issue_urls.get(database_type)

if issue_url:
if item.type == 'movie':
# override the id since ThemerrDB issues require the slug as part of the url
if item_agent == 'dev.lizardbyte.retroarcher-plex':
# get the slug and name from LizardByte db
try:
db_data = JSON.ObjectFromURL(
url='https://db.lizardbyte.dev/games/{}.json'.format(database_id),
cacheTime=CACHE_1DAY,
errors='strict'
)
issue_title = '{} ({})'.format(db_data['name'], year)
database_id = db_data['slug']
except Exception as e:
Log.Error('Error getting game data from LizardByte db: {}'.format(e))
issue_title = '{} ({})'.format(item.title, year)
database_id = None
issue_title = '{} ({})'.format(item.title, year)

Check warning on line 282 in Contents/Code/webapp.py

View check run for this annotation

Codecov / codecov/patch

Contents/Code/webapp.py#L282

Added line #L282 was not covered by tests

if database_id:

Check warning on line 284 in Contents/Code/webapp.py

View check run for this annotation

Codecov / codecov/patch

Contents/Code/webapp.py#L284

Added line #L284 was not covered by tests
# get the slug and name from LizardByte db
try:
db_data = JSON.ObjectFromURL(

Check warning on line 287 in Contents/Code/webapp.py

View check run for this annotation

Codecov / codecov/patch

Contents/Code/webapp.py#L286-L287

Added lines #L286 - L287 were not covered by tests
url='https://db.lizardbyte.dev/games/{}.json'.format(database_id),
cacheTime=CACHE_1DAY,
errors='strict'
)
except Exception as e:
Log.Error('Error getting game data from LizardByte db: {}'.format(e))
database_id = None

Check warning on line 294 in Contents/Code/webapp.py

View check run for this annotation

Codecov / codecov/patch

Contents/Code/webapp.py#L292-L294

Added lines #L292 - L294 were not covered by tests
else:
issue_title = '{} ({})'.format(db_data['name'], year)
database_id = db_data['slug']

Check warning on line 297 in Contents/Code/webapp.py

View check run for this annotation

Codecov / codecov/patch

Contents/Code/webapp.py#L296-L297

Added lines #L296 - L297 were not covered by tests
else:
issue_title = '{} ({})'.format(getattr(item, "originalTitle", None) or item.title, year)
else: # collections
issue_title = item.title

# override the id since ThemerrDB issues require the slug as part of the url
if item_agent == 'dev.lizardbyte.retroarcher-plex':
# get the slug and name from LizardByte db
try:
db_data = JSON.ObjectFromURL(
url='https://db.lizardbyte.dev/{}/all.json'.format(
database_type.rsplit('_', 1)[-1]),
cacheTime=CACHE_1DAY,
errors='strict'
)
issue_title = db_data[str(database_id)]['name']
database_id = db_data[str(database_id)]['slug']
except Exception as e:
Log.Error('Error getting collection data from LizardByte db: {}'.format(e))
database_id = None
if database_id:

Check warning on line 305 in Contents/Code/webapp.py

View check run for this annotation

Codecov / codecov/patch

Contents/Code/webapp.py#L305

Added line #L305 was not covered by tests
# get the slug and name from LizardByte db
try:
db_data = JSON.ObjectFromURL(

Check warning on line 308 in Contents/Code/webapp.py

View check run for this annotation

Codecov / codecov/patch

Contents/Code/webapp.py#L307-L308

Added lines #L307 - L308 were not covered by tests
url='https://db.lizardbyte.dev/{}/all.json'.format(
database_type.rsplit('_', 1)[-1]),
cacheTime=CACHE_1DAY,
errors='strict'
)
issue_title = db_data[str(database_id)]['name']
database_id = db_data[str(database_id)]['slug']
except Exception as e:
Log.Error('Error getting collection data from LizardByte db: {}'.format(e))
database_id = None

Check warning on line 318 in Contents/Code/webapp.py

View check run for this annotation

Codecov / codecov/patch

Contents/Code/webapp.py#L314-L318

Added lines #L314 - L318 were not covered by tests

if database_id:
# url encode the issue title
issue_title = quote_plus(issue_title)

item_issue_url = issue_url.format(issue_title, database_id)

if database_type and themerr_db_helper.item_exists(
if database_type and og_db and og_db_id and themerr_db_helper.item_exists(
database_type=database_type,
database=og_db,
id=og_db_id,
Expand Down
Loading