[110] tvdb date fix

pull/885/head
meisnate12 3 years ago
parent 78396323a7
commit 6c21fbeac0

@ -1 +1 @@
1.16.5-develop109 1.16.5-develop110

@ -598,9 +598,10 @@ class Cache:
cursor.execute("INSERT OR IGNORE INTO tvdb_data2(tvdb_id, type) VALUES(?, ?)", (obj.tvdb_id, "movie" if obj.is_movie else "show")) cursor.execute("INSERT OR IGNORE INTO tvdb_data2(tvdb_id, type) VALUES(?, ?)", (obj.tvdb_id, "movie" if obj.is_movie else "show"))
update_sql = "UPDATE tvdb_data2 SET title = ?, summary = ?, poster_url = ?, background_url = ?, " \ update_sql = "UPDATE tvdb_data2 SET title = ?, summary = ?, poster_url = ?, background_url = ?, " \
"release_date = ?, genres = ?, expiration_date = ? WHERE tvdb_id = ? AND type = ?" "release_date = ?, genres = ?, expiration_date = ? WHERE tvdb_id = ? AND type = ?"
tvdb_date = f"{str(obj.release_date.year).zfill(4)}-{str(obj.release_date.month).zfill(2)}-{str(obj.release_date.day).zfill(2)}" if obj.release_date else None
cursor.execute(update_sql, ( cursor.execute(update_sql, (
obj.title, obj.summary, obj.poster_url, obj.background_url, obj.release_date.strftime("%Y-%m-%d") if obj.release_date else None, obj.title, obj.summary, obj.poster_url, obj.background_url, tvdb_date, "|".join(obj.genres),
"|".join(obj.genres), expiration_date.strftime("%Y-%m-%d"), obj.tvdb_id, "movie" if obj.is_movie else "show" expiration_date.strftime("%Y-%m-%d"), obj.tvdb_id, "movie" if obj.is_movie else "show"
)) ))
def query_tvdb_map(self, tvdb_url, expiration): def query_tvdb_map(self, tvdb_url, expiration):

@ -148,16 +148,17 @@ class DataFile:
if not isinstance(template["default"], dict): if not isinstance(template["default"], dict):
raise Failed(f"{self.data_type} Error: template sub-attribute default is not a dictionary") raise Failed(f"{self.data_type} Error: template sub-attribute default is not a dictionary")
for dv in template["default"]: for dv in template["default"]:
final_key = dv
for k, v in variables.items(): for k, v in variables.items():
if f"<<{k}>>" in dv: if f"<<{k}>>" in final_key:
dv = dv.replace(f"<<{k}>>", str(v)) final_key = final_key.replace(f"<<{k}>>", str(v))
if dv not in optional: if final_key not in optional:
final_value = template["default"][dv] final_value = template["default"][dv]
for key, value in variables.items(): for key, value in variables.items():
if f"<<{key}>>" in str(final_value): if f"<<{key}>>" in str(final_value):
final_value = str(final_value).replace(f"<<{key}>>", str(value)) final_value = str(final_value).replace(f"<<{key}>>", str(value))
default[dv] = final_value default[final_key] = final_value
default[f"{dv}_encoded"] = requests.utils.quote(str(final_value)) default[f"{final_key}_encoded"] = requests.utils.quote(str(final_value))
if "optional" in template: if "optional" in template:
if template["optional"]: if template["optional"]:
@ -217,19 +218,17 @@ class DataFile:
else: else:
return og_txt return og_txt
for i in range(2):
for option in optional: for option in optional:
if option not in variables and f"<<{option}>>" in str(final_data): if option not in variables and f"<<{option}>>" in str(final_data):
raise Failed raise Failed
for i in range(2):
for variable, variable_data in variables.items(): for variable, variable_data in variables.items():
if (variable == "collection_name" or variable == "playlist_name") and _method in ["radarr_tag", "item_radarr_tag", "sonarr_tag", "item_sonarr_tag"]: if (variable == "collection_name" or variable == "playlist_name") and _method in ["radarr_tag", "item_radarr_tag", "sonarr_tag", "item_sonarr_tag"]:
final_data = scan_text(final_data, variable, variable_data.replace(",", "")) final_data = scan_text(final_data, variable, variable_data.replace(",", ""))
elif variable != "name": elif variable != "name":
final_data = scan_text(final_data, variable, variable_data) final_data = scan_text(final_data, variable, variable_data)
for dm, dd in default.items(): for dm, dd in default.items():
default_data = scan_text(final_data, dm, dd) final_data = scan_text(final_data, dm, dd)
if default_data:
final_data = default_data
return final_data return final_data
for method_name, attr_data in template.items(): for method_name, attr_data in template.items():
@ -588,7 +587,7 @@ class MetadataFile(DataFile):
logger.debug(f"Other Name: {other_name}") logger.debug(f"Other Name: {other_name}")
logger.debug(f"Keys (Title)") logger.debug(f"Keys (Title)")
for key, value in auto_list.items(): for key, value in auto_list.items():
logger.info(f" - {key}{'' if key == value else f' ({value})'}") logger.debug(f" - {key}{'' if key == value else f' ({value})'}")
used_keys = [] used_keys = []
for key, value in auto_list.items(): for key, value in auto_list.items():
@ -632,7 +631,9 @@ class MetadataFile(DataFile):
if collection_title in sync: if collection_title in sync:
sync.pop(collection_title) sync.pop(collection_title)
self.collections[collection_title] = col self.collections[collection_title] = col
if other_name: if other_name and not other_keys:
logger.warning(f"Config Warning: Other Collection {other_name} not needed")
elif other_name:
og_other = { og_other = {
"value": other_keys, "included_keys": include, "used_keys": used_keys, "value": other_keys, "included_keys": include, "used_keys": used_keys,
auto_type: other_keys, "key_name": other_name, "key": "other" auto_type: other_keys, "key_name": other_name, "key": "other"
@ -939,7 +940,7 @@ class MetadataFile(DataFile):
if self.edit_tags("label", season, season_dict, season_methods): if self.edit_tags("label", season, season_dict, season_methods):
updated = True updated = True
finish_edit(season, f"Season: {season_id}") finish_edit(season, f"Season: {season_id}")
self.library.item_images(season, season_dict, season_methods, asset_location=asset_location, top_item=item, self.library.item_images(season, season_dict, season_methods, asset_location=asset_location,
title=f"{item.title} Season {season.seasonNumber}", title=f"{item.title} Season {season.seasonNumber}",
image_name=f"Season{'0' if season.seasonNumber < 10 else ''}{season.seasonNumber}") image_name=f"Season{'0' if season.seasonNumber < 10 else ''}{season.seasonNumber}")
logger.info(f"Season {season_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}") logger.info(f"Season {season_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}")
@ -976,7 +977,7 @@ class MetadataFile(DataFile):
if self.edit_tags(tag_edit, episode, episode_dict, episode_methods): if self.edit_tags(tag_edit, episode, episode_dict, episode_methods):
updated = True updated = True
finish_edit(episode, f"Episode: {episode_str} in Season: {season_id}") finish_edit(episode, f"Episode: {episode_str} in Season: {season_id}")
self.library.item_images(episode, episode_dict, episode_methods, asset_location=asset_location, top_item=item, self.library.item_images(episode, episode_dict, episode_methods, asset_location=asset_location,
title=f"{item.title} {episode.seasonEpisode.upper()}", title=f"{item.title} {episode.seasonEpisode.upper()}",
image_name=episode.seasonEpisode.upper()) image_name=episode.seasonEpisode.upper())
logger.info(f"Episode {episode_str} in Season {season_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}") logger.info(f"Episode {episode_str} in Season {season_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}")
@ -1016,7 +1017,7 @@ class MetadataFile(DataFile):
if self.edit_tags(tag_edit, episode, episode_dict, episode_methods): if self.edit_tags(tag_edit, episode, episode_dict, episode_methods):
updated = True updated = True
finish_edit(episode, f"Episode: {episode_str} in Season: {season_id}") finish_edit(episode, f"Episode: {episode_str} in Season: {season_id}")
self.library.item_images(episode, episode_dict, episode_methods, asset_location=asset_location, top_item=item, self.library.item_images(episode, episode_dict, episode_methods, asset_location=asset_location,
title=f"{item.title} {episode.seasonEpisode.upper()}", title=f"{item.title} {episode.seasonEpisode.upper()}",
image_name=episode.seasonEpisode.upper()) image_name=episode.seasonEpisode.upper())
logger.info(f"Episode S{season_id}E{episode_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}") logger.info(f"Episode S{season_id}E{episode_id} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}")
@ -1056,7 +1057,7 @@ class MetadataFile(DataFile):
if self.edit_tags(tag_edit, album, album_dict, album_methods): if self.edit_tags(tag_edit, album, album_dict, album_methods):
updated = True updated = True
finish_edit(album, f"Album: {title}") finish_edit(album, f"Album: {title}")
self.library.item_images(album, album_dict, album_methods, asset_location=asset_location, top_item=item, self.library.item_images(album, album_dict, album_methods, asset_location=asset_location,
title=f"{item.title} Album {album.title}", image_name=album.title) title=f"{item.title} Album {album.title}", image_name=album.title)
logger.info(f"Album: {title} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}") logger.info(f"Album: {title} of {mapping_name} Details Update {'Complete' if updated else 'Not Needed'}")

@ -888,7 +888,7 @@ class Plex(Library):
logger.info(final) logger.info(final)
return final return final
def item_images(self, item, group, alias, asset_location=None, top_item=None, title=None, image_name=None): def item_images(self, item, group, alias, asset_location=None, title=None, image_name=None):
if title is None: if title is None:
title = item.title title = item.title
posters, backgrounds = util.get_image_dicts(group, alias) posters, backgrounds = util.get_image_dicts(group, alias)

@ -135,9 +135,9 @@ def get_image_dicts(group, alias):
if attr in alias: if attr in alias:
if group[alias[attr]]: if group[alias[attr]]:
if "poster" in attr: if "poster" in attr:
posters[attr] = ImageData(attr, group[alias[attr]], is_url="url" in attr) posters[attr] = group[alias[attr]]
else: else:
backgrounds[attr] = ImageData(attr, group[alias[attr]], is_poster=False, is_url="url" in attr) backgrounds[attr] = group[alias[attr]]
else: else:
logger.error(f"Metadata Error: {attr} attribute is blank") logger.error(f"Metadata Error: {attr} attribute is blank")
return posters, backgrounds return posters, backgrounds
@ -147,7 +147,7 @@ def pick_image(title, images, prioritize_assets, download_url_assets, item_dir,
if image_name is None: if image_name is None:
image_name = image_type image_name = image_type
if images: if images:
logger.debug(f"{len(images)} {image_type}s found:") logger.debug(f"{len(images)} {image_type}{'s' if len(images) > 1 else ''} found:")
for i in images: for i in images:
logger.debug(f"Method: {i} {image_type.capitalize()}: {images[i]}") logger.debug(f"Method: {i} {image_type.capitalize()}: {images[i]}")
is_url = True is_url = True

Loading…
Cancel
Save