Skip to content

Commit

Permalink
Fixed changing location for show. (#5795)
Browse files Browse the repository at this point in the history
* Fixed changing location for show.

* Added property validate_location to handle the ShowDirectoryNotFoundExceptions.

* Remove raw_location, as it's not needed anymore.

* flake8
  • Loading branch information
p0psicles authored and medariox committed Jan 12, 2019
1 parent 7f95aac commit 017a9c7
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 60 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- Fixed adding anime release group when adding show ([#5749](https://github.com/pymedusa/Medusa/pull/5749))
- Fixed Pushover debug log causing BraceException ([#5759](https://github.com/pymedusa/Medusa/pull/5759))
- Fixed torrent method Downloadstation not selected after restart ([#5761](https://github.com/pymedusa/Medusa/pull/5761))
- Fixed changing show location, should now also utilise the option 'CREATE_MISSING_SHOW_DIRS' ([#5795](https://github.com/pymedusa/Medusa/pull/5795))

-----

Expand Down
2 changes: 1 addition & 1 deletion medusa/clients/torrent/utorrent_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_torrent_subfolder(result):
root_dirs = app.ROOT_DIRS
if root_dirs:
root_location = root_dirs[int(root_dirs[0]) + 1]
torrent_path = result.series.raw_location
torrent_path = result.series.location

if root_dirs and root_location != torrent_path:
# Subfolder is under root, but possibly not directly under
Expand Down
18 changes: 9 additions & 9 deletions medusa/metadata/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,19 @@ def _has_season_all_banner(self, show_obj):
return self._check_exists(self.get_season_all_banner_path(show_obj))

def get_show_file_path(self, show_obj):
return os.path.join(show_obj.location, self._show_metadata_filename)
return os.path.join(show_obj.validate_location, self._show_metadata_filename)

def get_episode_file_path(self, ep_obj):
return replace_extension(ep_obj.location, self._ep_nfo_extension)
return replace_extension(ep_obj.validate_location, self._ep_nfo_extension)

def get_fanart_path(self, show_obj):
return os.path.join(show_obj.location, self.fanart_name)
return os.path.join(show_obj.validate_location, self.fanart_name)

def get_poster_path(self, show_obj):
return os.path.join(show_obj.location, self.poster_name)
return os.path.join(show_obj.validate_location, self.poster_name)

def get_banner_path(self, show_obj):
return os.path.join(show_obj.location, self.banner_name)
return os.path.join(show_obj.validate_location, self.banner_name)

def get_image_path(self, show_obj, image_type):
"""Based on the image_type (banner, poster, fanart) call the correct method, and return the path."""
Expand Down Expand Up @@ -224,7 +224,7 @@ def get_season_poster_path(show_obj, season):
else:
season_poster_filename = u'season' + str(season).zfill(2)

return os.path.join(show_obj.location, season_poster_filename + u'-poster.jpg')
return os.path.join(show_obj.validate_location, season_poster_filename + u'-poster.jpg')

@staticmethod
def get_season_banner_path(show_obj, season):
Expand All @@ -241,13 +241,13 @@ def get_season_banner_path(show_obj, season):
else:
season_banner_filename = u'season' + str(season).zfill(2)

return os.path.join(show_obj.location, season_banner_filename + u'-banner.jpg')
return os.path.join(show_obj.validate_location, season_banner_filename + u'-banner.jpg')

def get_season_all_poster_path(self, show_obj):
return os.path.join(show_obj.location, self.season_all_poster_name)
return os.path.join(show_obj.validate_location, self.season_all_poster_name)

def get_season_all_banner_path(self, show_obj):
return os.path.join(show_obj.location, self.season_all_banner_name)
return os.path.join(show_obj.validate_location, self.season_all_banner_name)

# pylint: disable=unused-argument,no-self-use
def _show_data(self, show_obj):
Expand Down
2 changes: 1 addition & 1 deletion medusa/metadata/kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def get_season_poster_path(show_obj, season):
else:
season_poster_filename = 'season' + text_type(season).zfill(2)

return os.path.join(show_obj.location, season_poster_filename + '.tbn')
return os.path.join(show_obj.validate_location, season_poster_filename + '.tbn')


# present a standard "interface" from the module
Expand Down
12 changes: 6 additions & 6 deletions medusa/metadata/media_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def get_season_poster_path(show_obj, season):
If no season folder exists, None is returned
"""

dir_list = [x for x in os.listdir(show_obj.location) if
os.path.isdir(os.path.join(show_obj.location, x))]
dir_list = [x for x in os.listdir(show_obj.validate_location) if
os.path.isdir(os.path.join(show_obj.validate_location, x))]

season_dir_regex = r'^Season\s+(\d+)$'

Expand Down Expand Up @@ -170,7 +170,7 @@ def get_season_poster_path(show_obj, season):
log.debug(u'Using {path}/folder.jpg as season directory for season {number}',
{u'path': season_dir, u'number': season})

return os.path.join(show_obj.location, season_dir, u'folder.jpg')
return os.path.join(show_obj.validate_location, season_dir, u'folder.jpg')

@staticmethod
def get_season_banner_path(show_obj, season):
Expand All @@ -180,8 +180,8 @@ def get_season_banner_path(show_obj, season):
If no season folder exists, None is returned
"""

dir_list = [x for x in os.listdir(show_obj.location) if
os.path.isdir(os.path.join(show_obj.location, x))]
dir_list = [x for x in os.listdir(show_obj.validate_location) if
os.path.isdir(os.path.join(show_obj.validate_location, x))]

season_dir_regex = r'^Season\s+(\d+)$'

Expand Down Expand Up @@ -212,7 +212,7 @@ def get_season_banner_path(show_obj, season):
log.debug(u'Using {path}/banner.jpg as season directory for season {number}',
{u'path': season_dir, u'number': season})

return os.path.join(show_obj.location, season_dir, u'banner.jpg')
return os.path.join(show_obj.validate_location, season_dir, u'banner.jpg')

def _show_data(self, show_obj):
"""
Expand Down
6 changes: 3 additions & 3 deletions medusa/metadata/wdtv.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ def get_season_poster_path(show_obj, season):
If no season folder exists, None is returned
"""

dir_list = [x for x in os.listdir(show_obj.location) if
os.path.isdir(os.path.join(show_obj.location, x))]
dir_list = [x for x in os.listdir(show_obj.validate_location) if
os.path.isdir(os.path.join(show_obj.validate_location, x))]

season_dir_regex = r'^Season\s+(\d+)$'

Expand Down Expand Up @@ -159,7 +159,7 @@ def get_season_poster_path(show_obj, season):
log.debug('Using {location}/folder.jpg as season dir for season {number}',
{'location': season_dir, 'number': season})

return os.path.join(show_obj.location, season_dir, 'folder.jpg')
return os.path.join(show_obj.validate_location, season_dir, 'folder.jpg')

def _ep_data(self, ep_obj):
"""
Expand Down
4 changes: 2 additions & 2 deletions medusa/post_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,11 +1203,11 @@ def process(self):
# find the destination folder
try:
proper_path = ep_obj.proper_path()
proper_absolute_path = os.path.join(ep_obj.series.location, proper_path)
proper_absolute_path = os.path.join(ep_obj.series.validate_location, proper_path)
dest_path = os.path.dirname(proper_absolute_path)
except ShowDirectoryNotFoundException:
raise EpisodePostProcessingFailedException(u"Unable to post-process an episode if the show dir '{0}' "
u"doesn't exist, quitting".format(ep_obj.series.raw_location))
u"doesn't exist, quitting".format(ep_obj.series.location))

self.log(u'Destination folder for this episode: {0}'.format(dest_path), logger.DEBUG)

Expand Down
4 changes: 2 additions & 2 deletions medusa/server/api/v1/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ def run(self):
# absolute vs relative vs broken
show_path = None
try:
show_path = show_obj.location
show_path = show_obj.validate_location
except ShowDirectoryNotFoundException:
pass

Expand Down Expand Up @@ -1903,7 +1903,7 @@ def run(self):
show_dict['quality_details'] = {'initial': any_qualities, 'archive': best_qualities}

try:
show_dict['location'] = show_obj.location
show_dict['location'] = show_obj.validate_location
except ShowDirectoryNotFoundException:
show_dict['location'] = ''

Expand Down
2 changes: 1 addition & 1 deletion medusa/server/api/v2/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def http_patch(self, series_slug, path_param=None):
'config.scene': BooleanField(series, 'scene'),
'config.sports': BooleanField(series, 'sports'),
'config.paused': BooleanField(series, 'paused'),
'config.location': StringField(series, '_location'),
'config.location': StringField(series, 'location'),
'config.airByDate': BooleanField(series, 'air_by_date'),
'config.subtitlesEnabled': BooleanField(series, 'subtitles'),
'config.release.requiredWords': ListField(series, 'release_required_words'),
Expand Down
8 changes: 4 additions & 4 deletions medusa/server/web/home/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def displayShow(self, indexername=None, seriesid=None, ):
}]

try:
show_loc = (series_obj.location, True)
show_loc = (series_obj.validate_location, True)
except ShowDirectoryNotFoundException:
show_loc = (series_obj._location, False) # pylint: disable=protected-access

Expand Down Expand Up @@ -1146,7 +1146,7 @@ def snatchSelection(self, indexername, seriesid, season=None, episode=None, manu
}]

try:
show_loc = (series_obj.location, True)
show_loc = (series_obj.validate_location, True)
except ShowDirectoryNotFoundException:
show_loc = (series_obj._location, False) # pylint: disable=protected-access

Expand Down Expand Up @@ -2016,7 +2016,7 @@ def testRename(self, indexername=None, seriesid=None):
return self._genericMessage('Error', 'Show not in show list')

try:
series_obj.location # @UnusedVariable
series_obj.validate_location # @UnusedVariable
except ShowDirectoryNotFoundException:
return self._genericMessage('Error', 'Can\'t rename episodes when the show dir is missing.')

Expand Down Expand Up @@ -2051,7 +2051,7 @@ def doRename(self, indexername=None, seriesid=None, eps=None):
return self._genericMessage('Error', error_message)

try:
series_obj.location # @UnusedVariable
series_obj.validate_location # @UnusedVariable
except ShowDirectoryNotFoundException:
return self._genericMessage('Error', 'Can\'t rename episodes when the show dir is missing.')

Expand Down
2 changes: 1 addition & 1 deletion medusa/show_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ def run(self):
)

try:
self.show.location
self.show.validate_location
except ShowDirectoryNotFoundException:
log.warning(
"Can't perform rename on {series_name} when the show dir is missing.",
Expand Down
2 changes: 1 addition & 1 deletion medusa/tv/episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ def load_from_indexer(self, season=None, episode=None, tvapi=None, cached_season
'{id}: {series} episode statuses unchanged. Location is missing: {location}', {
'id': self.series.series_id,
'series': self.series.name,
'location': self.series.raw_location,
'location': self.series.location,
}
)
return
Expand Down
Loading

0 comments on commit 017a9c7

Please sign in to comment.