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

Commit

Permalink
fix(dashboard): fix issue where local items could prevent ui cache fr…
Browse files Browse the repository at this point in the history
…om completing (#341)
  • Loading branch information
ReenigneArcher authored Jan 28, 2024
1 parent 65d6a60 commit b0d8452
Showing 1 changed file with 34 additions and 36 deletions.
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 @@ def cache_data():
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 @@ def cache_data():

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)

if database_id:
# 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'
)
except Exception as e:
Log.Error('Error getting game data from LizardByte db: {}'.format(e))
database_id = None
else:
issue_title = '{} ({})'.format(db_data['name'], year)
database_id = db_data['slug']
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:
# 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:
# 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

0 comments on commit b0d8452

Please sign in to comment.