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

Feature/fix force update metadata #10237

Merged
merged 10 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- Add column sorting for the add new show page search results ([10217](https://github.com/pymedusa/Medusa/pull/10217))
- Add series start year as a renaming option ([10183](https://github.com/pymedusa/Medusa/pull/10183))
- Remove git username/password authentication. No longer supported by github. ([10144](https://github.com/pymedusa/Medusa/pull/10144))
- Add option to allow for overwriting nfo files. ([10237](https://github.com/pymedusa/Medusa/pull/10237))
- Improve kodi nfo file creation. ([10237](https://github.com/pymedusa/Medusa/pull/10237))

#### Fixes
- Fix displayShow search subtitle button ([10214](https://github.com/pymedusa/Medusa/pull/10214))
Expand Down
14 changes: 7 additions & 7 deletions medusa/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,13 +1001,13 @@ def initialize(self, console_logging=True):
app.AUTO_ANIME_TO_LIST = bool(check_setting_int(app.CFG, 'ANIME', 'auto_anime_to_list', 0))
app.SHOWLISTS_DEFAULT_ANIME = check_setting_list(app.CFG, 'ANIME', 'showlist_default_anime', [])

app.METADATA_KODI = check_setting_list(app.CFG, 'General', 'metadata_kodi', ['0'] * 10, transform=int)
app.METADATA_KODI_12PLUS = check_setting_list(app.CFG, 'General', 'metadata_kodi_12plus', ['0'] * 10, transform=int)
app.METADATA_MEDIABROWSER = check_setting_list(app.CFG, 'General', 'metadata_mediabrowser', ['0'] * 10, transform=int)
app.METADATA_PS3 = check_setting_list(app.CFG, 'General', 'metadata_ps3', ['0'] * 10, transform=int)
app.METADATA_WDTV = check_setting_list(app.CFG, 'General', 'metadata_wdtv', ['0'] * 10, transform=int)
app.METADATA_TIVO = check_setting_list(app.CFG, 'General', 'metadata_tivo', ['0'] * 10, transform=int)
app.METADATA_MEDE8ER = check_setting_list(app.CFG, 'General', 'metadata_mede8er', ['0'] * 10, transform=int)
app.METADATA_KODI = check_setting_list(app.CFG, 'General', 'metadata_kodi', ['0'] * 11, transform=int)
app.METADATA_KODI_12PLUS = check_setting_list(app.CFG, 'General', 'metadata_kodi_12plus', ['0'] * 11, transform=int)
app.METADATA_MEDIABROWSER = check_setting_list(app.CFG, 'General', 'metadata_mediabrowser', ['0'] * 11, transform=int)
app.METADATA_PS3 = check_setting_list(app.CFG, 'General', 'metadata_ps3', ['0'] * 11, transform=int)
app.METADATA_WDTV = check_setting_list(app.CFG, 'General', 'metadata_wdtv', ['0'] * 11, transform=int)
app.METADATA_TIVO = check_setting_list(app.CFG, 'General', 'metadata_tivo', ['0'] * 11, transform=int)
app.METADATA_MEDE8ER = check_setting_list(app.CFG, 'General', 'metadata_mede8er', ['0'] * 11, transform=int)

app.HOME_LAYOUT = check_setting_str(app.CFG, 'GUI', 'home_layout', 'poster')
app.HISTORY_LAYOUT = check_setting_str(app.CFG, 'GUI', 'history_layout', 'detailed')
Expand Down
2 changes: 1 addition & 1 deletion medusa/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self):
self.CONFIG_FILE = None

# This is the version of the config we EXPECT to find
self.CONFIG_VERSION = 11
self.CONFIG_VERSION = 12

# Default encryption version (0 for None)
self.ENCRYPTION_VERSION = 0
Expand Down
26 changes: 25 additions & 1 deletion medusa/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,8 @@ def __init__(self, config_obj):
8: 'Convert Plex setting keys',
9: 'Added setting "enable_manualsearch" for providers (dynamic setting)',
10: 'Convert all csv config items to lists',
11: 'Convert provider ratio type string to int'
11: 'Convert provider ratio type string to int',
12: 'Add new metadata option overwrite_nfo'
}

def migrate_config(self):
Expand Down Expand Up @@ -1279,3 +1280,26 @@ def _migrate_v11(self):
provider.ratio = -1
elif isinstance(provider.ratio, str):
provider.ratio = int(provider.ratio)

def _migrate_v12(self):
"""Add new option to metadata providers."""
def add_new_option(metadata_prov):
if len(metadata_prov) == 10:
metadata_prov.append(0)
return metadata_prov

app.METADATA_KODI = check_setting_list(app.CFG, 'General', 'metadata_kodi', ['0'] * 11, transform=int)
app.METADATA_KODI_12PLUS = check_setting_list(app.CFG, 'General', 'metadata_kodi_12plus', ['0'] * 11, transform=int)
app.METADATA_MEDIABROWSER = check_setting_list(app.CFG, 'General', 'metadata_mediabrowser', ['0'] * 11, transform=int)
app.METADATA_PS3 = check_setting_list(app.CFG, 'General', 'metadata_ps3', ['0'] * 11, transform=int)
app.METADATA_WDTV = check_setting_list(app.CFG, 'General', 'metadata_wdtv', ['0'] * 11, transform=int)
app.METADATA_TIVO = check_setting_list(app.CFG, 'General', 'metadata_tivo', ['0'] * 11, transform=int)
app.METADATA_MEDE8ER = check_setting_list(app.CFG, 'General', 'metadata_mede8er', ['0'] * 11, transform=int)

app.METADATA_KODI = add_new_option(app.METADATA_KODI)
app.METADATA_KODI_12PLUS = add_new_option(app.METADATA_KODI_12PLUS)
app.METADATA_MEDIABROWSER = add_new_option(app.METADATA_MEDIABROWSER)
app.METADATA_PS3 = add_new_option(app.METADATA_PS3)
app.METADATA_WDTV = add_new_option(app.METADATA_WDTV)
app.METADATA_TIVO = add_new_option(app.METADATA_TIVO)
app.METADATA_MEDE8ER = add_new_option(app.METADATA_MEDE8ER)
11 changes: 7 additions & 4 deletions medusa/metadata/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class GenericMetadata(object):
def __init__(self, show_metadata=False, episode_metadata=False, fanart=False,
poster=False, banner=False, episode_thumbnails=False,
season_posters=False, season_banners=False,
season_all_poster=False, season_all_banner=False):
season_all_poster=False, season_all_banner=False, overwrite_nfo=False):

self.name = u'Generic'
self._ep_nfo_extension = u'nfo'
Expand All @@ -81,6 +81,7 @@ def __init__(self, show_metadata=False, episode_metadata=False, fanart=False,
self.season_banners = season_banners
self.season_all_poster = season_all_poster
self.season_all_banner = season_all_banner
self.overwrite_nfo = overwrite_nfo

# Web UI metadata template (override when subclassing)
self.eg_show_metadata = '<i>not supported</i>'
Expand All @@ -100,7 +101,7 @@ def __init__(self, show_metadata=False, episode_metadata=False, fanart=False,
def get_config(self):
config_list = [self.show_metadata, self.episode_metadata, self.fanart, self.poster, self.banner,
self.episode_thumbnails, self.season_posters, self.season_banners, self.season_all_poster,
self.season_all_banner]
self.season_all_banner, self.overwrite_nfo]
return u'|'.join([str(int(x)) for x in config_list])

def get_id(self):
Expand All @@ -124,6 +125,7 @@ def set_config(self, provider_options):
self.season_banners = config_list[7]
self.season_all_poster = config_list[8]
self.season_all_banner = config_list[9]
self.overwrite_nfo = config_list[10]

@staticmethod
def _check_exists(location):
Expand Down Expand Up @@ -266,7 +268,7 @@ def _ep_data(self, ep_obj):
return None

def create_show_metadata(self, show_obj):
if self.show_metadata and show_obj and not self._has_show_metadata(show_obj):
if self.show_metadata and show_obj and (not self._has_show_metadata(show_obj) or self.overwrite_nfo):
log.debug(
u'Metadata provider {name} creating series metadata for {series}',
{u'name': self.name, u'series': show_obj.name}
Expand All @@ -275,7 +277,7 @@ def create_show_metadata(self, show_obj):
return False

def create_episode_metadata(self, ep_obj):
if self.episode_metadata and ep_obj and not self.has_episode_metadata(ep_obj):
if self.episode_metadata and ep_obj and (not self.has_episode_metadata(ep_obj) or self.overwrite_nfo):
log.debug(
u'Metadata provider {name} creating episode metadata for {episode}',
{u'name': self.name, u'episode': ep_obj.pretty_name()}
Expand Down Expand Up @@ -1058,6 +1060,7 @@ def to_json(self):
data['seasonBanners'] = self.season_banners
data['seasonAllPoster'] = self.season_all_poster
data['seasonAllBanner'] = self.season_all_banner
data['overwriteNfo'] = self.overwrite_nfo

data['example'] = {}
data['example']['banner'] = self.eg_banner
Expand Down
40 changes: 31 additions & 9 deletions medusa/metadata/kodi_12plus.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from medusa import helpers
from medusa.app import TVDB_API_KEY
from medusa.helper.common import dateFormat, episode_num
from medusa.helper.common import episode_num
from medusa.indexers.api import indexerApi
from medusa.indexers.config import INDEXER_TVDBV2
from medusa.indexers.exceptions import IndexerEpisodeNotFound, IndexerSeasonNotFound
Expand Down Expand Up @@ -116,15 +116,30 @@ def _show_data(self, series_obj):
title.text = my_show['seriesname']

if getattr(my_show, 'rating', None):
rating = etree.SubElement(tv_node, 'rating')
rating.text = text_type(my_show['rating'])
ratings = etree.SubElement(tv_node, 'ratings')
rating = etree.SubElement(ratings, 'rating')
rating.set('name', series_obj.identifier.indexer.slug)
rating.set('max', '10')
rating.set('default', 'true')
value = etree.SubElement(rating, 'value')
value.text = text_type(str(my_show['rating']))
votes = etree.SubElement(rating, 'votes')
votes.text = ''

if series_obj.imdb_id and series_obj.imdb_rating and series_obj.imdb_votes:
rating_imdb = etree.SubElement(ratings, 'rating')
rating_imdb.set('name', 'imdb')
rating_imdb.set('max', '10')
rating_imdb.set('default', 'false')
value = etree.SubElement(rating_imdb, 'value')
value.text = series_obj.imdb_rating
votes = etree.SubElement(rating_imdb, 'votes')
votes.text = str(series_obj.imdb_votes)

if getattr(my_show, 'firstaired', None):
try:
year_text = text_type(datetime.datetime.strptime(my_show['firstaired'], dateFormat).year)
if year_text:
year = etree.SubElement(tv_node, 'year')
year.text = year_text
year = etree.SubElement(tv_node, 'premiered')
year.text = my_show['firstaired']
except Exception:
pass

Expand Down Expand Up @@ -318,8 +333,15 @@ def _ep_data(self, ep_obj):
# watched.text = 'false'

if getattr(my_ep, 'rating', None):
rating = etree.SubElement(episode, 'rating')
rating.text = text_type(my_ep['rating'])
ratings = etree.SubElement(episode, 'ratings')
rating = etree.SubElement(ratings, 'rating')
rating.set('name', ep_obj.indexer_name)
rating.set('max', '10')
rating.set('default', 'true')
value = etree.SubElement(rating, 'value')
value.text = text_type(my_ep['rating'])
votes = etree.SubElement(rating, 'votes')
votes.text = ''

if getattr(my_ep, 'writer', None) and isinstance(my_ep['writer'], string_types):
for writer in self._split_info(my_ep['writer']):
Expand Down
2 changes: 1 addition & 1 deletion medusa/metadata/ps3.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def retrieveShowMetadata(self, folder):
# no show metadata generated, we abort this lookup function
return None, None, None

def create_show_metadata(self, show_obj):
def create_show_metadata(self, show_obj, force=False):
pass

def update_show_indexer_metadata(self, show_obj):
Expand Down
2 changes: 1 addition & 1 deletion medusa/metadata/tivo.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def retrieveShowMetadata(self, folder):
# no show metadata generated, we abort this lookup function
return None, None, None

def create_show_metadata(self, show_obj):
def create_show_metadata(self, show_obj, force=False):
pass

def update_show_indexer_metadata(self, show_obj):
Expand Down
2 changes: 1 addition & 1 deletion medusa/metadata/wdtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def retrieveShowMetadata(self, folder):
# no show metadata generated, we abort this lookup function
return None, None, None

def create_show_metadata(self, show_obj):
def create_show_metadata(self, show_obj, force=False):
pass

def update_show_indexer_metadata(self, show_obj):
Expand Down
1 change: 1 addition & 0 deletions medusa/server/api/v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ def patch(self, target, value):
('seasonBanners', 'season_banners'),
('seasonAllPoster', 'season_all_poster'),
('seasonAllBanner', 'season_all_banner'),
('overwriteNfo', 'overwrite_nfo'),
])

try:
Expand Down
2 changes: 1 addition & 1 deletion medusa/server/web/home/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ def deleteShow(self, showslug=None, full=0):
def refreshShow(self, showslug=None):
# @TODO: Replace with status=refresh from PATCH /api/v2/show/{id}
identifier = SeriesIdentifier.from_slug(showslug)
error, series_obj = Show.refresh(identifier.indexer.slug, identifier.id)
error, series_obj = Show.refresh(identifier.indexer.slug, identifier.id, force=True)

# This is a show validation error
if error is not None and series_obj is None:
Expand Down
4 changes: 2 additions & 2 deletions medusa/show/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def pause(indexer_id, series_id, pause=None):
return None, show

@staticmethod
def refresh(indexer_id, series_id):
def refresh(indexer_id, series_id, force=False):
"""
Try to refresh a show.

Expand All @@ -233,7 +233,7 @@ def refresh(indexer_id, series_id):
return error, series_obj

try:
app.show_queue_scheduler.action.refreshShow(series_obj)
app.show_queue_scheduler.action.refreshShow(series_obj, force=force)
except CantRefreshShowException as exception:
return ex(exception), series_obj

Expand Down
2 changes: 1 addition & 1 deletion tests/apiv2/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def gen_schema(data):
@pytest.fixture
def config_metadata(monkeypatch, app_config):
# initialize metadata_providers
default_config = ['0'] * 10
default_config = ['0'] * 11
providers = [
(default_config, metadata.kodi),
(default_config, metadata.kodi_12plus),
Expand Down
Loading