Fix error updating shows with certain paths.

Change refactor scene_numbering.
Change update LimeTorrents icon.
This commit is contained in:
JackDandy 2018-09-07 17:23:19 +01:00
parent 41a0cea90a
commit 139dd5a571
7 changed files with 296 additions and 271 deletions

View file

@ -1,4 +1,14 @@
### 0.17.4 (2018-09-01 03:00:00 UTC) ### 0.17.5 (2018-09-08 13:20:00 UTC)
* Fix error updating shows with certain paths
* Fix getting XEM absolute numbers for show
* Fix IMDb info load for redirected ids
* Fix flags on displayShow (under Linux)
* Change refactor scene numbering
* Change update LimeTorrents icon
### 0.17.4 (2018-09-01 03:00:00 UTC)
* Fix typo * Fix typo

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

After

Width:  |  Height:  |  Size: 744 B

View file

@ -20,7 +20,8 @@
## ##
#set $eps = $getVar('episodes', None) or [$episode] #set $eps = $getVar('episodes', None) or [$episode]
#for $ep in $eps #for $ep in $eps
#set $ep_str = '%sx%s' % ($ep['season'], $ep['episode']) #set $ep_key = ($ep['season'], $ep['episode'])
#set $ep_str = '%sx%s' % $ep_key
#set $epLoc = $ep['location'] #set $epLoc = $ep['location']
#set never_aired = 0 < int($ep['season']) and 1 == int($ep['airdate']) #set never_aired = 0 < int($ep['season']) and 1 == int($ep['airdate'])
<tr class="#echo ' '.join([$Overview.overviewStrings[$ep_cats[$ep_str]], ('', 'airdate-never')[$never_aired], ('', 'archived')[$ARCHIVED == $Quality.splitCompositeStatus(int($ep['status']))[0]]])#"> <tr class="#echo ' '.join([$Overview.overviewStrings[$ep_cats[$ep_str]], ('', 'airdate-never')[$never_aired], ('', 'archived')[$ARCHIVED == $Quality.splitCompositeStatus(int($ep['status']))[0]]])#">
@ -50,40 +51,32 @@
#slurp #slurp
#if $scene #if $scene
#set $dfltSeas, $dfltEpis = (0, 0) if ($ep['season'], $ep['episode']) not in $xem_numbering else $xem_numbering[($ep['season'], $ep['episode'])] #set $dfltSeas, $dfltEpis = $xem_numbering.get($ep_key, (0, 0))
<td align="center"> <td align="center">
<input type="text" placeholder="#echo '%sx%s' % ($dfltSeas, $dfltEpis)#" size="6" maxlength="8" <input type="text" placeholder="#echo '%sx%s' % ($dfltSeas, $dfltEpis)#" size="6" maxlength="8"
class="sceneSeasonXEpisode form-control input-scene" data-for-season="$ep['season']" data-for-episode="$ep['episode']" class="sceneSeasonXEpisode form-control input-scene" data-for-season="$ep['season']" data-for-episode="$ep['episode']"
id="sceneSeasonXEpisode_#echo '%s_%s_%s' % ($show.indexerid, $ep['season'], $ep['episode'])#" id="sceneSeasonXEpisode_#echo '%s_%s_%s' % (($show.indexerid,) + $ep_key)#"
title="Change the value here if scene numbering differs from the indexer episode numbering" title="Change the value here if scene numbering differs from the indexer episode numbering"
#if ($ep['season'], $ep['episode']) in $scene_numbering #set $value = '%sx%s' % $scene_numbering.get($ep_key, ('', ''))
#set $scSeas, $scEpis = $scene_numbering[($ep['season'], $ep['episode'])] #set $value = ($value, '')['x' == $value]
value="#echo '%sx%s' % ($scSeas, $scEpis)#" value="$value"
#else
value=""
#end if
style="padding:0; text-align:center; max-width:60px"> style="padding:0; text-align:center; max-width:60px">
</td> </td>
#elif $scene_anime #elif $scene_anime
## todo: $xem_absolute_numbering[$ep['absolute_number']] is tuple key: $xem_absolute_numbering[($ep['season'], $ep['episode'])] #set $dfltAbsolute = $xem_absolute_numbering.get($ep_key, 0)
#set $dfltAbsolute = 0 if $ep['absolute_number'] not in $xem_absolute_numbering else $xem_absolute_numbering[$ep['absolute_number']]
<td align="center"> <td align="center">
<input type="text" placeholder="$dfltAbsolute" size="6" maxlength="8" <input type="text" placeholder="$dfltAbsolute" size="6" maxlength="8"
class="sceneAbsolute form-control input-scene" data-for-absolute="$ep['absolute_number']" class="sceneAbsolute form-control input-scene" data-for-season="$ep['season']" data-for-episode="$ep['episode']"
id="sceneAbsolute_#echo '%s_%s' % ($show.indexerid, $ep['absolute_number'])#" id="sceneAbsolute_#echo '%s_%s_%s' % (($show.indexerid,) + $ep_key)#"
title="Change the value here if scene absolute numbering differs from the indexer absolute numbering" title="Change the value here if scene absolute numbering differs from the indexer absolute numbering"
#if $ep['absolute_number'] in $scene_absolute_numbering value="$scene_absolute_numbering.get($ep_key, '')"
value="$scene_absolute_numbering[$ep['absolute_number']]"
#else
value=""
#end if
style="padding:0; text-align:center; max-width:60px"> style="padding:0; text-align:center; max-width:60px">
</td> </td>
#end if #end if
#slurp #slurp
<td class="col-name"> <td class="col-name">
<img src="$sbRoot/images/info32.png" width="16" height="16" alt="" class="plotInfo#echo '%s' %\ <img src="$sbRoot/images/info32.png" width="16" height="16" alt="" class="plotInfo#echo '%s' %\
('None opacity40', ('" id="plot_info_%s_%s_%s' % ($show.indexerid, $ep['season'], $ep['episode'])))[None is not $ep['description'] and '' != $ep['description']]#"> ('None opacity40', ('" id="plot_info_%s_%s_%s' % (($show.indexerid,) + $ep_key)))[None is not $ep['description'] and '' != $ep['description']]#">
#set $cls = (' class="tba grey-text"', '')['good' == $Overview.overviewStrings[$ep_cats[$ep_str]]] #set $cls = (' class="tba grey-text"', '')['good' == $Overview.overviewStrings[$ep_cats[$ep_str]]]
#if not $ep['name'] or 'TBA' == $ep['name']#<em${cls}>TBA</em>#else#$ep['name']#end if# #if not $ep['name'] or 'TBA' == $ep['name']#<em${cls}>TBA</em>#else#$ep['name']#end if#
</td> </td>

View file

@ -126,16 +126,17 @@ $(document).ready(function() {
}, },
function(data) { function(data) {
// Set the values we get back // Set the values we get back
$('#sceneSeasonXEpisode_' + showId + '_' + forSeason + '_' + forEpisode).val( var value = ((null === data.sceneSeason || null === data.sceneEpisode)
(null === data.sceneSeason || null === data.sceneEpisode)
? '' : data.sceneSeason + 'x' + data.sceneEpisode); ? '' : data.sceneSeason + 'x' + data.sceneEpisode);
$('#sceneSeasonXEpisode_' + showId + '_' + forSeason + '_' + forEpisode)
.val(value).attr('value', value);
if (!data.success) if (!data.success)
alert(data.errorMessage ? data.errorMessage : 'Update failed.'); alert(data.errorMessage ? data.errorMessage : 'Update failed.');
} }
); );
} }
function setAbsoluteSceneNumbering(forAbsolute, sceneAbsolute) { function setAbsoluteSceneNumbering(forSeason, forEpisode, sceneAbsolute) {
var showId = $('#showID').val(), indexer = $('#indexer').val(); var showId = $('#showID').val(), indexer = $('#indexer').val();
if ('' === sceneAbsolute) if ('' === sceneAbsolute)
@ -145,13 +146,15 @@ $(document).ready(function() {
{ {
'show': showId, 'show': showId,
'indexer': indexer, 'indexer': indexer,
'forAbsolute': forAbsolute, 'forSeason': forSeason,
'forEpisode': forEpisode,
'sceneAbsolute': sceneAbsolute 'sceneAbsolute': sceneAbsolute
}, },
function(data) { function(data) {
// Set the values we get back // Set the values we get back
$('#sceneAbsolute_' + showId + '_' + forAbsolute).val( var value = (null === data.sceneAbsolute ? '' : data.sceneAbsolute);
(null === data.sceneAbsolute) ? '' : data.sceneAbsolute); $('#sceneAbsolute_' + showId + '_' + forSeason + '_' + forEpisode)
.val(value).attr('value', value);
if (!data.success) if (!data.success)
alert(data.errorMessage ? data.errorMessage : 'Update failed.'); alert(data.errorMessage ? data.errorMessage : 'Update failed.');
} }
@ -250,13 +253,14 @@ $(document).ready(function() {
$(obj).find('.sceneAbsolute').change(function() { $(obj).find('.sceneAbsolute').change(function() {
// Strip non-numeric characters // Strip non-numeric characters
$(this).val($(this).val().replace(/[^0-9xX]*/g, '')); $(this).val($(this).val().replace(/[^0-9]*/g, ''));
var forAbsolute = $(this).attr('data-for-absolute'), var forSeason = $(this).attr('data-for-season'),
m = $(this).val().match(/^(\d{1,3})$/i), forEpisode = $(this).attr('data-for-episode'),
m = $(this).val().match(/^(\d{1,4})$/i),
sceneAbsolute = m && m[1] || null; sceneAbsolute = m && m[1] || null;
setAbsoluteSceneNumbering(forAbsolute, sceneAbsolute); setAbsoluteSceneNumbering(forSeason, forEpisode, sceneAbsolute);
}); });
}); });
} }

View file

@ -30,6 +30,7 @@ import sickbeard
from sickbeard import logger from sickbeard import logger
from sickbeard import db from sickbeard import db
from sickbeard.exceptions import ex from sickbeard.exceptions import ex
from sickbeard.helpers import tryInt
from sickbeard.scene_exceptions import xem_ids_list from sickbeard.scene_exceptions import xem_ids_list
@ -37,10 +38,11 @@ def get_scene_numbering(indexer_id, indexer, season, episode, fallback_to_xem=Tr
""" """
Returns a tuple, (season, episode), with the scene numbering (if there is one), Returns a tuple, (season, episode), with the scene numbering (if there is one),
otherwise returns the xem numbering (if fallback_to_xem is set), otherwise otherwise returns the xem numbering (if fallback_to_xem is set), otherwise
returns the TVDB and TVRAGE numbering. returns the TVDB numbering.
(so the return values will always be set) (so the return values will always be set)
@param indexer_id: int @param indexer_id: int
@param indexer: int
@param season: int @param season: int
@param episode: int @param episode: int
@param fallback_to_xem: bool If set (the default), check xem for matches if there is no local scene numbering @param fallback_to_xem: bool If set (the default), check xem for matches if there is no local scene numbering
@ -69,14 +71,16 @@ def find_scene_numbering(indexer_id, indexer, season, episode):
Same as get_scene_numbering(), but returns None if scene numbering is not set Same as get_scene_numbering(), but returns None if scene numbering is not set
""" """
if None is indexer_id or None is season or None is episode: if None is indexer_id or None is season or None is episode:
return season, episode return
indexer_id = int(indexer_id) indexer_id = int(indexer_id)
indexer = int(indexer) indexer = int(indexer)
my_db = db.DBConnection() my_db = db.DBConnection()
rows = my_db.select( rows = my_db.select(
'SELECT scene_season, scene_episode FROM scene_numbering WHERE indexer = ? and indexer_id = ? and season = ? and episode = ? and (scene_season or scene_episode) != 0', 'SELECT scene_season, scene_episode'
' FROM scene_numbering'
' WHERE indexer = ? AND indexer_id = ? AND season = ? AND episode = ? AND (scene_season OR scene_episode) != 0',
[indexer, indexer_id, season, episode]) [indexer, indexer_id, season, episode])
if rows: if rows:
@ -87,25 +91,29 @@ def get_scene_absolute_numbering(indexer_id, indexer, absolute_number, season, e
""" """
Returns a tuple, (season, episode), with the scene numbering (if there is one), Returns a tuple, (season, episode), with the scene numbering (if there is one),
otherwise returns the xem numbering (if fallback_to_xem is set), otherwise otherwise returns the xem numbering (if fallback_to_xem is set), otherwise
returns the TVDB and TVRAGE numbering. returns the TVDB numbering.
(so the return values will always be set) (so the return values will always be set)
@param indexer_id: int @param indexer_id: int
@param indexer: int
@param absolute_number: int @param absolute_number: int
@param season: int
@param episode: int
@param fallback_to_xem: bool If set (the default), check xem for matches if there is no local scene numbering @param fallback_to_xem: bool If set (the default), check xem for matches if there is no local scene numbering
@return: (int, int) a tuple with (season, episode) @return: (int, int) a tuple with (season, episode)
""" """
if None is indexer_id or None is absolute_number: has_sxe = None is not season and None is not episode
if None is indexer_id or (None is absolute_number and not has_sxe):
return absolute_number return absolute_number
indexer_id = int(indexer_id) indexer_id = int(indexer_id)
indexer = int(indexer) indexer = int(indexer)
show_obj = sickbeard.helpers.findCertainShow(sickbeard.showList, indexer_id) show_obj = sickbeard.helpers.findCertainShow(sickbeard.showList, indexer_id)
if show_obj and not show_obj.is_scene: if show_obj and not show_obj.is_scene and not has_sxe:
return absolute_number return absolute_number
result = find_scene_absolute_numbering(indexer_id, indexer, absolute_number) result = find_scene_absolute_numbering(indexer_id, indexer, absolute_number, season, episode)
if result: if result:
return result return result
else: else:
@ -116,56 +124,63 @@ def get_scene_absolute_numbering(indexer_id, indexer, absolute_number, season, e
return absolute_number return absolute_number
def find_scene_absolute_numbering(indexer_id, indexer, absolute_number): def find_scene_absolute_numbering(indexer_id, indexer, absolute_number, season=None, episode=None):
""" """
Same as get_scene_numbering(), but returns None if scene numbering is not set Same as get_scene_numbering(), but returns None if scene numbering is not set
""" """
if None is indexer_id or None is absolute_number: has_sxe = None is not season and None is not episode
return absolute_number if None is indexer_id or (None is absolute_number and not has_sxe):
return
indexer_id = int(indexer_id) indexer_id = int(indexer_id)
indexer = int(indexer) indexer = int(indexer)
my_db = db.DBConnection() my_db = db.DBConnection()
sql_vars, cond = (([absolute_number], 'and absolute_number = ?'),
([season, episode], 'and season = ? AND episode = ?'))[has_sxe]
rows = my_db.select( rows = my_db.select(
'SELECT scene_absolute_number FROM scene_numbering WHERE indexer = ? and indexer_id = ? and absolute_number = ? and scene_absolute_number != 0', 'SELECT scene_absolute_number'
[indexer, indexer_id, absolute_number]) ' FROM scene_numbering'
' WHERE indexer = ? AND indexer_id = ? %s AND scene_absolute_number != 0' % cond,
[indexer, indexer_id] + sql_vars)
if rows: if rows:
return int(rows[0]['scene_absolute_number']) return int(rows[0]['scene_absolute_number'])
def get_indexer_numbering(indexer_id, indexer, sceneSeason, sceneEpisode, fallback_to_xem=True): def get_indexer_numbering(indexer_id, indexer, scene_season, scene_episode, fallback_to_xem=True):
""" """
Returns a tuple, (season, episode) with the TVDB and TVRAGE numbering for (sceneSeason, sceneEpisode) Returns a tuple, (season, episode) with the TVDB numbering for (sceneSeason, sceneEpisode)
(this works like the reverse of get_scene_numbering) (this works like the reverse of get_scene_numbering)
""" """
if None is indexer_id or None is sceneSeason or None is sceneEpisode: if None is indexer_id or None is scene_season or None is scene_episode:
return sceneSeason, sceneEpisode return scene_season, scene_episode
indexer_id = int(indexer_id) indexer_id = int(indexer_id)
indexer = int(indexer) indexer = int(indexer)
my_db = db.DBConnection() my_db = db.DBConnection()
rows = my_db.select( rows = my_db.select(
'SELECT season, episode FROM scene_numbering WHERE indexer = ? and indexer_id = ? and scene_season = ? and scene_episode = ?', 'SELECT season, episode'
[indexer, indexer_id, sceneSeason, sceneEpisode]) ' FROM scene_numbering'
' WHERE indexer = ? AND indexer_id = ? AND scene_season = ? AND scene_episode = ?',
[indexer, indexer_id, scene_season, scene_episode])
if rows: if rows:
return int(rows[0]['season']), int(rows[0]['episode']) return int(rows[0]['season']), int(rows[0]['episode'])
else: else:
if fallback_to_xem: if fallback_to_xem:
return get_indexer_numbering_for_xem(indexer_id, indexer, sceneSeason, sceneEpisode) return get_indexer_numbering_for_xem(indexer_id, indexer, scene_season, scene_episode)
return sceneSeason, sceneEpisode return scene_season, scene_episode
def get_indexer_absolute_numbering(indexer_id, indexer, sceneAbsoluteNumber, fallback_to_xem=True, scene_season=None): def get_indexer_absolute_numbering(indexer_id, indexer, scene_absolute_number, fallback_to_xem=True, scene_season=None):
""" """
Returns a tuple, (season, episode, absolute_number) with the TVDB and TVRAGE numbering for (sceneAbsoluteNumber) Returns a tuple, (season, episode, absolute_number) with the TVDB numbering for (sceneAbsoluteNumber)
(this works like the reverse of get_absolute_numbering) (this works like the reverse of get_absolute_numbering)
""" """
if None is indexer_id or None is sceneAbsoluteNumber: if None is indexer_id or None is scene_absolute_number:
return sceneAbsoluteNumber return scene_absolute_number
indexer_id = int(indexer_id) indexer_id = int(indexer_id)
indexer = int(indexer) indexer = int(indexer)
@ -173,23 +188,27 @@ def get_indexer_absolute_numbering(indexer_id, indexer, sceneAbsoluteNumber, fal
my_db = db.DBConnection() my_db = db.DBConnection()
if None is scene_season: if None is scene_season:
rows = my_db.select( rows = my_db.select(
'SELECT absolute_number FROM scene_numbering WHERE indexer = ? and indexer_id = ? and scene_absolute_number = ?', 'SELECT absolute_number'
[indexer, indexer_id, sceneAbsoluteNumber]) ' FROM scene_numbering'
' WHERE indexer = ? AND indexer_id = ? AND scene_absolute_number = ?',
[indexer, indexer_id, scene_absolute_number])
else: else:
rows = my_db.select( rows = my_db.select(
'SELECT absolute_number FROM scene_numbering WHERE indexer = ? and indexer_id = ? and scene_absolute_number = ? and scene_season = ?', 'SELECT absolute_number'
[indexer, indexer_id, sceneAbsoluteNumber, scene_season]) ' FROM scene_numbering'
' WHERE indexer = ? AND indexer_id = ? AND scene_absolute_number = ? AND scene_season = ?',
[indexer, indexer_id, scene_absolute_number, scene_season])
if rows: if rows:
return int(rows[0]['absolute_number']) return int(rows[0]['absolute_number'])
else: else:
if fallback_to_xem: if fallback_to_xem:
return get_indexer_absolute_numbering_for_xem(indexer_id, indexer, sceneAbsoluteNumber, scene_season) return get_indexer_absolute_numbering_for_xem(indexer_id, indexer, scene_absolute_number, scene_season)
return sceneAbsoluteNumber return scene_absolute_number
def set_scene_numbering(indexer_id, indexer, season=None, episode=None, absolute_number=None, sceneSeason=None, def set_scene_numbering(indexer_id, indexer, season=None, episode=None, absolute_number=None, scene_season=None,
sceneEpisode=None, sceneAbsolute=None): scene_episode=None, scene_absolute=None, anime=False):
""" """
Set scene numbering for a season/episode. Set scene numbering for a season/episode.
To clear the scene numbering, leave both sceneSeason and sceneEpisode as None. To clear the scene numbering, leave both sceneSeason and sceneEpisode as None.
@ -207,17 +226,49 @@ def set_scene_numbering(indexer_id, indexer, season=None, episode=None, absolute
'INSERT OR IGNORE INTO scene_numbering (indexer, indexer_id, season, episode) VALUES (?,?,?,?)', 'INSERT OR IGNORE INTO scene_numbering (indexer, indexer_id, season, episode) VALUES (?,?,?,?)',
[indexer, indexer_id, season, episode]) [indexer, indexer_id, season, episode])
# sxe replaced abs_num as key, migrate data with only abs
_, _, ep_absolute_number = _get_sea(indexer, indexer_id, season, episode)
rows = my_db.select(
'SELECT scene_season, scene_episode, scene_absolute_number'
' FROM scene_numbering'
' WHERE indexer = ? AND indexer_id = ? AND season IS NULL AND episode IS NULL AND absolute_number = ?',
[indexer, indexer_id, ep_absolute_number])
if not len(rows):
update, values = (('scene_absolute_number = ?', [scene_absolute]),
('scene_season = ?, scene_episode = ?', [scene_season, scene_episode]))[not anime]
else:
for row in rows:
scene_season = scene_season or row['scene_season']
scene_episode = scene_episode or row['scene_episode']
scene_absolute = scene_absolute or row['scene_absolute_number']
update, values = ('scene_season = ?, scene_episode = ?, scene_absolute_number = ?',
[scene_season, scene_episode, scene_absolute])
my_db.action( my_db.action(
'UPDATE scene_numbering SET scene_season = ?, scene_episode = ? WHERE indexer = ? and indexer_id = ? and season = ? and episode = ?', 'UPDATE scene_numbering'
[sceneSeason, sceneEpisode, indexer, indexer_id, season, episode]) ' SET %s' % update +
' WHERE indexer = ? AND indexer_id = ? AND season = ? AND episode = ?',
values + [indexer, indexer_id, season, episode])
my_db.action(
'DELETE'
' FROM scene_numbering'
' WHERE indexer = ? AND indexer_id = ? AND'
' ((absolute_number = ? OR (season = ? AND episode = ?))'
' AND scene_season IS NULL AND scene_episode IS NULL AND scene_absolute_number IS NULL)',
[indexer, indexer_id, ep_absolute_number, season, episode])
elif absolute_number: elif absolute_number:
my_db.action( my_db.action(
'INSERT OR IGNORE INTO scene_numbering (indexer, indexer_id, absolute_number) VALUES (?,?,?)', 'INSERT OR IGNORE INTO scene_numbering (indexer, indexer_id, absolute_number) VALUES (?,?,?)',
[indexer, indexer_id, absolute_number]) [indexer, indexer_id, absolute_number])
my_db.action( my_db.action(
'UPDATE scene_numbering SET scene_absolute_number = ? WHERE indexer = ? and indexer_id = ? and absolute_number = ?', 'UPDATE scene_numbering'
[sceneAbsolute, indexer, indexer_id, absolute_number]) ' SET scene_absolute_number = ?'
' WHERE indexer = ? AND indexer_id = ? AND absolute_number = ?',
[scene_absolute, indexer, indexer_id, absolute_number])
def find_xem_numbering(indexer_id, indexer, season, episode): def find_xem_numbering(indexer_id, indexer, season, episode):
@ -226,6 +277,7 @@ def find_xem_numbering(indexer_id, indexer, season, episode):
Refreshes/Loads as needed. Refreshes/Loads as needed.
@param indexer_id: int @param indexer_id: int
@param indexer: int
@param season: int @param season: int
@param episode: int @param episode: int
@return: (int, int) a tuple of scene_season, scene_episode, or None if there is no special mapping. @return: (int, int) a tuple of scene_season, scene_episode, or None if there is no special mapping.
@ -240,7 +292,9 @@ def find_xem_numbering(indexer_id, indexer, season, episode):
my_db = db.DBConnection() my_db = db.DBConnection()
rows = my_db.select( rows = my_db.select(
'SELECT scene_season, scene_episode FROM tv_episodes WHERE indexer = ? and showid = ? and season = ? and episode = ? and (scene_season or scene_episode) != 0', 'SELECT scene_season, scene_episode'
' FROM tv_episodes'
' WHERE indexer = ? AND showid = ? AND season = ? AND episode = ? AND (scene_season OR scene_episode) != 0',
[indexer, indexer_id, season, episode]) [indexer, indexer_id, season, episode])
if rows: if rows:
@ -253,7 +307,10 @@ def find_xem_absolute_numbering(indexer_id, indexer, absolute_number, season, ep
Refreshes/Loads as needed. Refreshes/Loads as needed.
@param indexer_id: int @param indexer_id: int
@param indexer: int
@param absolute_number: int @param absolute_number: int
@param season: int
@param episode: int
@return: int @return: int
""" """
if None is indexer_id or None is absolute_number: if None is indexer_id or None is absolute_number:
@ -266,24 +323,27 @@ def find_xem_absolute_numbering(indexer_id, indexer, absolute_number, season, ep
my_db = db.DBConnection() my_db = db.DBConnection()
rows = my_db.select( rows = my_db.select(
'SELECT scene_absolute_number FROM tv_episodes WHERE indexer = ? and showid = ? and season = ? and episode = ? and scene_absolute_number != 0', 'SELECT scene_absolute_number'
' FROM tv_episodes'
' WHERE indexer = ? AND showid = ? AND season = ? AND episode = ? AND scene_absolute_number != 0',
[indexer, indexer_id, season, episode]) [indexer, indexer_id, season, episode])
if rows: if rows:
return int(rows[0]['scene_absolute_number']) return int(rows[0]['scene_absolute_number'])
def get_indexer_numbering_for_xem(indexer_id, indexer, sceneSeason, sceneEpisode): def get_indexer_numbering_for_xem(indexer_id, indexer, scene_season, scene_episode):
""" """
Reverse of find_xem_numbering: lookup a tvdb season and episode using scene numbering Reverse of find_xem_numbering: lookup a tvdb season and episode using scene numbering
@param indexer_id: int @param indexer_id: int
@param sceneSeason: int @param indexer: int
@param sceneEpisode: int @param scene_season: int
@param scene_episode: int
@return: (int, int) a tuple of (season, episode) @return: (int, int) a tuple of (season, episode)
""" """
if None is indexer_id or None is sceneSeason or None is sceneEpisode: if None is indexer_id or None is scene_season or None is scene_episode:
return sceneSeason, sceneEpisode return scene_season, scene_episode
indexer_id = int(indexer_id) indexer_id = int(indexer_id)
indexer = int(indexer) indexer = int(indexer)
@ -292,25 +352,29 @@ def get_indexer_numbering_for_xem(indexer_id, indexer, sceneSeason, sceneEpisode
my_db = db.DBConnection() my_db = db.DBConnection()
rows = my_db.select( rows = my_db.select(
'SELECT season, episode FROM tv_episodes WHERE indexer = ? and showid = ? and scene_season = ? and scene_episode = ?', 'SELECT season, episode'
[indexer, indexer_id, sceneSeason, sceneEpisode]) ' FROM tv_episodes'
' WHERE indexer = ? AND showid = ? AND scene_season = ? AND scene_episode = ?',
[indexer, indexer_id, scene_season, scene_episode])
if rows: if rows:
return int(rows[0]['season']), int(rows[0]['episode']) return int(rows[0]['season']), int(rows[0]['episode'])
return sceneSeason, sceneEpisode return scene_season, scene_episode
def get_indexer_absolute_numbering_for_xem(indexer_id, indexer, sceneAbsoluteNumber, scene_season=None): def get_indexer_absolute_numbering_for_xem(indexer_id, indexer, scene_absolute_number, scene_season=None):
""" """
Reverse of find_xem_numbering: lookup a tvdb season and episode using scene numbering Reverse of find_xem_numbering: lookup a tvdb season and episode using scene numbering
@param indexer_id: int @param indexer_id: int
@param sceneAbsoluteNumber: int @param indexer: int
@param scene_absolute_number: int
@param scene_season: int/None
@return: int @return: int
""" """
if None is indexer_id or None is sceneAbsoluteNumber: if None is indexer_id or None is scene_absolute_number:
return sceneAbsoluteNumber return scene_absolute_number
indexer_id = int(indexer_id) indexer_id = int(indexer_id)
indexer = int(indexer) indexer = int(indexer)
@ -320,141 +384,137 @@ def get_indexer_absolute_numbering_for_xem(indexer_id, indexer, sceneAbsoluteNum
my_db = db.DBConnection() my_db = db.DBConnection()
if None is scene_season: if None is scene_season:
rows = my_db.select( rows = my_db.select(
'SELECT absolute_number FROM tv_episodes WHERE indexer = ? and showid = ? and scene_absolute_number = ?', 'SELECT absolute_number'
[indexer, indexer_id, sceneAbsoluteNumber]) ' FROM tv_episodes'
' WHERE indexer = ? AND showid = ? AND scene_absolute_number = ?',
[indexer, indexer_id, scene_absolute_number])
else: else:
rows = my_db.select( rows = my_db.select(
'SELECT absolute_number FROM tv_episodes WHERE indexer = ? and showid = ? and scene_absolute_number = ? and scene_season = ?', 'SELECT absolute_number'
[indexer, indexer_id, sceneAbsoluteNumber, scene_season]) ' FROM tv_episodes'
' WHERE indexer = ? AND showid = ? AND scene_absolute_number = ? AND scene_season = ?',
[indexer, indexer_id, scene_absolute_number, scene_season])
if rows: if rows:
return int(rows[0]['absolute_number']) return int(rows[0]['absolute_number'])
return sceneAbsoluteNumber return scene_absolute_number
def get_scene_numbering_for_show(indexer_id, indexer): def get_scene_numbering_for_show(indexer_id, indexer):
""" """
Returns a dict of (season, episode) : (sceneSeason, sceneEpisode) mappings Returns a dict of (season, episode) : (scene_season, scene_episode) mappings
for an entire show. Both the keys and values of the dict are tuples. for an entire show. Both the keys and values of the dict are tuples.
Will be empty if there are no scene numbers set Will be empty if no scene numbers are set
""" """
if None is indexer_id: return _get_numbering_for_show('scene_numbering', indexer, indexer_id)
return {}
indexer_id = int(indexer_id)
indexer = int(indexer)
my_db = db.DBConnection()
rows = my_db.select(
'SELECT season, episode, scene_season, scene_episode FROM scene_numbering WHERE indexer = ? and indexer_id = ? and (scene_season or scene_episode) != 0 ORDER BY season, episode',
[indexer, indexer_id])
result = {}
for row in rows:
season = int(row['season'])
episode = int(row['episode'])
scene_season = int(row['scene_season'])
scene_episode = int(row['scene_episode'])
result[(season, episode)] = (scene_season, scene_episode)
return result
def get_xem_numbering_for_show(indexer_id, indexer): def get_xem_numbering_for_show(indexer_id, indexer):
""" """
Returns a dict of (season, episode) : (sceneSeason, sceneEpisode) mappings Returns a dict of (season, episode) : (scene_season, scene_episode) mappings
for an entire show. Both the keys and values of the dict are tuples. for an entire show. Both the keys and values of the dict are tuples.
Will be empty if there are no scene numbers set in xem Will be empty if no scene numbers are set in xem
""" """
if None is indexer_id: return _get_numbering_for_show('tv_episodes', indexer, indexer_id)
return {}
indexer_id = int(indexer_id)
indexer = int(indexer)
xem_refresh(indexer_id, indexer) def _get_numbering_for_show(tbl, indexer, indexer_id):
my_db = db.DBConnection()
rows = my_db.select(
'SELECT season, episode, scene_season, scene_episode FROM tv_episodes WHERE indexer = ? and showid = ? and (scene_season or scene_episode) != 0 ORDER BY season, episode',
[indexer, indexer_id])
result = {} result = {}
for row in rows:
season = int(row['season'])
episode = int(row['episode'])
scene_season = int(row['scene_season'])
scene_episode = int(row['scene_episode'])
result[(season, episode)] = (scene_season, scene_episode) if None is not indexer_id:
if 'tv_episodes' == tbl:
xem_refresh(indexer_id, indexer)
my_db = db.DBConnection()
# noinspection SqlResolve
rows = my_db.select(
'SELECT season, episode, scene_season, scene_episode'
' FROM %s' % tbl +
' WHERE indexer = ? AND %s = ?' % ('indexer_id', 'showid')['tv_episodes' == tbl] +
' AND (scene_season OR scene_episode) != 0'
' ORDER BY season, episode',
[int(indexer), int(indexer_id)])
for row in rows:
season, episode = tryInt(row['season'], None), tryInt(row['episode'], None)
if None is not season and None is not episode:
scene_season, scene_episode = tryInt(row['scene_season'], None), tryInt(row['scene_episode'], None)
if None is not scene_season and None is not scene_episode:
result[(season, episode)] = (scene_season, scene_episode)
return result return result
def get_scene_absolute_numbering_for_show(indexer_id, indexer): def get_scene_absolute_numbering_for_show(indexer_id, indexer):
""" """
Returns a dict of (season, episode) : (sceneSeason, sceneEpisode) mappings Returns a dict of (season, episode) : scene_absolute_number mappings for an entire show.
for an entire show. Both the keys and values of the dict are tuples. Will be empty if no scene numbers are set
Will be empty if there are no scene numbers set
""" """
if None is indexer_id: return _get_absolute_numbering_for_show('scene_numbering', indexer, indexer_id)
return {}
indexer_id = int(indexer_id)
indexer = int(indexer)
my_db = db.DBConnection()
rows = my_db.select(
'SELECT absolute_number, scene_absolute_number FROM scene_numbering WHERE indexer = ? and indexer_id = ? and scene_absolute_number != 0 ORDER BY absolute_number',
[indexer, indexer_id])
result = {}
for row in rows:
absolute_number = int(row['absolute_number'])
scene_absolute_number = int(row['scene_absolute_number'])
result[absolute_number] = scene_absolute_number
return result
def get_xem_absolute_numbering_for_show(indexer_id, indexer): def get_xem_absolute_numbering_for_show(indexer_id, indexer):
""" """
Returns a dict of (season, episode) : (sceneSeason, sceneEpisode) mappings Returns a dict of (season, episode) : scene_absolute_number mappings for an entire show.
for an entire show. Both the keys and values of the dict are tuples. Will be empty if no scene numbers are set in xem
Will be empty if there are no scene numbers set in xem
""" """
if None is indexer_id: return _get_absolute_numbering_for_show('tv_episodes', indexer, indexer_id)
return {}
indexer_id = int(indexer_id)
indexer = int(indexer)
xem_refresh(indexer_id, indexer) def _get_absolute_numbering_for_show(tbl, indexer, indexer_id):
result = {} result = {}
my_db = db.DBConnection()
rows = my_db.select(
'SELECT season, episode, scene_absolute_number FROM tv_episodes WHERE indexer = ? and showid = ? and scene_absolute_number != 0 ORDER BY season, episode',
[indexer, indexer_id])
for row in rows: if None is not indexer_id:
season = int(row['season']) if 'tv_episodes' == tbl:
episode = int(row['episode']) xem_refresh(indexer_id, indexer)
scene_absolute_number = int(row['scene_absolute_number'])
result[(season, episode)] = scene_absolute_number my_db = db.DBConnection()
# noinspection SqlResolve
rows = my_db.select(
'SELECT season, episode, absolute_number, scene_absolute_number'
' FROM %s' % tbl +
' WHERE indexer = ? AND %s = ?' % ('indexer_id', 'showid')['tv_episodes' == tbl] +
' AND scene_absolute_number != 0'
' ORDER BY season, episode',
[int(indexer), int(indexer_id)])
for row in rows:
season, episode, abs_num = map(lambda x: tryInt(row[x], None), ('season', 'episode', 'absolute_number'))
if None is season and None is episode and None is not abs_num:
season, episode, _ = _get_sea(indexer, indexer_id, absolute_number=abs_num)
if None is not season and None is not episode:
scene_absolute_number = tryInt(row['scene_absolute_number'], None)
if None is not scene_absolute_number:
result[(season, episode)] = scene_absolute_number
return result return result
def _get_sea(indexer, indexer_id, season=None, episode=None, absolute_number=None):
show_obj = sickbeard.helpers.find_show_by_id(sickbeard.showList, {indexer: indexer_id},
no_mapped_ids=True)
if show_obj:
ep_obj = None
if None is not absolute_number:
ep_obj = show_obj.getEpisode(absolute_number=absolute_number)
elif None is not season and None is not episode:
ep_obj = show_obj.getEpisode(season, episode)
if None is not ep_obj:
season, episode, absolute_number = ep_obj.season, ep_obj.episode, ep_obj.absolute_number
return season, episode, absolute_number
def xem_refresh(indexer_id, indexer, force=False): def xem_refresh(indexer_id, indexer, force=False):
""" """
Refresh data from xem for a tv show Refresh data from xem for a tv show
@param indexer_id: int @param indexer_id: int
@param indexer: int
@param force: bool
""" """
if None is indexer_id: if None is indexer_id:
return return
@ -472,8 +532,11 @@ def xem_refresh(indexer_id, indexer, force=False):
max_refresh_age_secs = 86400 # 1 day max_refresh_age_secs = 86400 # 1 day
my_db = db.DBConnection() my_db = db.DBConnection()
rows = my_db.select('SELECT last_refreshed FROM xem_refresh WHERE indexer = ? and indexer_id = ?', rows = my_db.select(
[indexer, indexer_id]) 'SELECT last_refreshed'
' FROM xem_refresh'
' WHERE indexer = ? AND indexer_id = ?',
[indexer, indexer_id])
if rows: if rows:
last_refresh = int(rows[0]['last_refreshed']) last_refresh = int(rows[0]['last_refreshed'])
refresh = int(time.mktime(datetime.datetime.today().timetuple())) > last_refresh + max_refresh_age_secs refresh = int(time.mktime(datetime.datetime.today().timetuple())) > last_refresh + max_refresh_age_secs
@ -493,32 +556,24 @@ def xem_refresh(indexer_id, indexer, force=False):
try: try:
parsed_json = sickbeard.helpers.getURL(url, json=True, timeout=90) parsed_json = sickbeard.helpers.getURL(url, json=True, timeout=90)
if not parsed_json or '' == parsed_json: if not parsed_json or '' == parsed_json:
logger.log(u'No XEM data for show %s on %s' % (indexer_id, sickbeard.indexerApi(indexer).name), logger.MESSAGE) logger.log(u'No XEM data for show %s on %s' % (
indexer_id, sickbeard.indexerApi(indexer).name), logger.MESSAGE)
return return
if 'success' in parsed_json['result']: if 'success' in parsed_json['result']:
cl = [] cl = []
for entry in parsed_json['data']: for entry in parsed_json['data']:
if 'scene' in entry: # use scene2 for doubles
cl.append([ scene = 'scene%s' % ('', '_2')['scene_2' in entry]
'UPDATE tv_episodes SET scene_season = ?, scene_episode = ?, scene_absolute_number = ? WHERE showid = ? AND season = ? AND episode = ?', cl.append([
[entry['scene']['season'], 'UPDATE tv_episodes'
entry['scene']['episode'], ' SET scene_season = ?, scene_episode = ?, scene_absolute_number = ?'
entry['scene']['absolute'], ' WHERE showid = ? AND season = ? AND episode = ?',
indexer_id, [entry[scene]['season'], entry[scene]['episode'], entry[scene]['absolute'],
entry[sickbeard.indexerApi(indexer).config['xem_origin']]['season'], indexer_id,
entry[sickbeard.indexerApi(indexer).config['xem_origin']]['episode'] entry[sickbeard.indexerApi(indexer).config['xem_origin']]['season'],
]]) entry[sickbeard.indexerApi(indexer).config['xem_origin']]['episode']
if 'scene_2' in entry: # for doubles ]])
cl.append([
'UPDATE tv_episodes SET scene_season = ?, scene_episode = ?, scene_absolute_number = ? WHERE showid = ? AND season = ? AND episode = ?',
[entry['scene_2']['season'],
entry['scene_2']['episode'],
entry['scene_2']['absolute'],
indexer_id,
entry[sickbeard.indexerApi(indexer).config['xem_origin']]['season'],
entry[sickbeard.indexerApi(indexer).config['xem_origin']]['episode']
]])
if 0 < len(cl): if 0 < len(cl):
my_db = db.DBConnection() my_db = db.DBConnection()
@ -534,60 +589,18 @@ def xem_refresh(indexer_id, indexer, force=False):
def fix_xem_numbering(indexer_id, indexer): def fix_xem_numbering(indexer_id, indexer):
"""
Returns a dict of (season, episode) : (sceneSeason, sceneEpisode) mappings
for an entire show. Both the keys and values of the dict are tuples.
Will be empty if there are no scene numbers set in xem
"""
if None is indexer_id: if None is indexer_id:
return {} return {}
indexer_id = int(indexer_id) indexer_id = int(indexer_id)
indexer = int(indexer) indexer = int(indexer)
# query = [{
# "name": self.show.name,
# "seasons": [{
# "episodes": [{
# "episode_number": None,
# "name": None
# }],
# "season_number": None,
# }],
# "/tv/tv_program/number_of_seasons": [],
# "/tv/tv_program/number_of_episodes": [],
# "/tv/tv_program/thetvdb_id": [],
# "/tv/tv_program/tvrage_id": [],
# "type": "/tv/tv_program",
# }]
#
#
# url = 'https://www.googleapis.com/freebase/v1/mqlread'
# api_key = "AIzaSyCCHNp4dhVHxJYzbLiCE4y4a1rgTnX4fDE"
# params = {
# 'query': json.dumps(query),
# 'key': api_key
# }
#
#
# def get_from_api(url, params=None):
# """Build request and return results
# """
# import xmltodict
#
# response = requests.get(url, params=params)
# if response.status_code == 200:
# try:
# return response.json()
# except ValueError:
# return xmltodict.parse(response.text)['Data']
#
# # Get query results
# tmp = get_from_api(url, params=params)['result']
my_db = db.DBConnection() my_db = db.DBConnection()
rows = my_db.select( rows = my_db.select(
'SELECT season, episode, absolute_number, scene_season, scene_episode, scene_absolute_number FROM tv_episodes WHERE indexer = ? and showid = ?', 'SELECT season, episode, absolute_number, scene_season, scene_episode, scene_absolute_number'
' FROM tv_episodes'
' WHERE indexer = ? AND showid = ?',
[indexer, indexer_id]) [indexer, indexer_id])
last_absolute_number = None last_absolute_number = None
@ -654,7 +667,9 @@ def fix_xem_numbering(indexer_id, indexer):
if update_absolute_number: if update_absolute_number:
cl.append([ cl.append([
'UPDATE tv_episodes SET absolute_number = ? WHERE showid = ? AND season = ? AND episode = ?', 'UPDATE tv_episodes'
' SET absolute_number = ?'
' WHERE showid = ? AND season = ? AND episode = ?',
[absolute_number, [absolute_number,
indexer_id, indexer_id,
season, season,
@ -664,7 +679,9 @@ def fix_xem_numbering(indexer_id, indexer):
if update_scene_season: if update_scene_season:
cl.append([ cl.append([
'UPDATE tv_episodes SET scene_season = ? WHERE showid = ? AND season = ? AND episode = ?', 'UPDATE tv_episodes'
' SET scene_season = ?'
' WHERE showid = ? AND season = ? AND episode = ?',
[scene_season, [scene_season,
indexer_id, indexer_id,
season, season,
@ -674,7 +691,9 @@ def fix_xem_numbering(indexer_id, indexer):
if update_scene_episode: if update_scene_episode:
cl.append([ cl.append([
'UPDATE tv_episodes SET scene_episode = ? WHERE showid = ? AND season = ? AND episode = ?', 'UPDATE tv_episodes'
' SET scene_episode = ?'
' WHERE showid = ? AND season = ? AND episode = ?',
[scene_episode, [scene_episode,
indexer_id, indexer_id,
season, season,
@ -684,7 +703,9 @@ def fix_xem_numbering(indexer_id, indexer):
if update_scene_absolute_number: if update_scene_absolute_number:
cl.append([ cl.append([
'UPDATE tv_episodes SET scene_absolute_number = ? WHERE showid = ? AND season = ? AND episode = ?', 'UPDATE tv_episodes'
' SET scene_absolute_number = ?'
' WHERE showid = ? AND season = ? AND episode = ?',
[scene_absolute_number, [scene_absolute_number,
indexer_id, indexer_id,
season, season,
@ -697,37 +718,34 @@ def fix_xem_numbering(indexer_id, indexer):
my_db.mass_action(cl) my_db.mass_action(cl)
def set_scene_numbering_helper(indexerid, indexer, forSeason=None, forEpisode=None, forAbsolute=None, def set_scene_numbering_helper(indexerid, indexer, for_season=None, for_episode=None, for_absolute=None,
sceneSeason=None, sceneEpisode=None, sceneAbsolute=None): scene_season=None, scene_episode=None, scene_absolute=None):
# sanitize: # sanitize:
indexerid = None if indexerid in [None, 'null', ''] else int(indexerid) indexerid = None if indexerid in [None, 'null', ''] else int(indexerid)
indexer = None if indexer in [None, 'null', ''] else int(indexer) indexer = None if indexer in [None, 'null', ''] else int(indexer)
show_obj = sickbeard.helpers.find_show_by_id(sickbeard.showList, {indexer: indexerid}, no_mapped_ids=True) show_obj = sickbeard.helpers.find_show_by_id(sickbeard.showList, {indexer: indexerid}, no_mapped_ids=True)
if not show_obj: if not show_obj:
result = {'success': False} return {'success': False}
return result
for_season = None if for_season in [None, 'null', ''] else int(for_season)
for_episode = None if for_episode in [None, 'null', ''] else int(for_episode)
ep_args = {'show': indexerid, 'season': for_season, 'episode': for_episode}
scene_args = {'indexer': indexer, 'indexer_id': indexerid, 'season': for_season, 'episode': for_episode}
if not show_obj.is_anime: if not show_obj.is_anime:
for_season = None if forSeason in [None, 'null', ''] else int(forSeason) scene_season = None if scene_season in [None, 'null', ''] else int(scene_season)
for_episode = None if forEpisode in [None, 'null', ''] else int(forEpisode) scene_episode = None if scene_episode in [None, 'null', ''] else int(scene_episode)
scene_season = None if sceneSeason in [None, 'null', ''] else int(sceneSeason)
scene_episode = None if sceneEpisode in [None, 'null', ''] else int(sceneEpisode)
action_log = u'Set episode scene numbering to %sx%s for episode %sx%s of "%s"' \ action_log = u'Set episode scene numbering to %sx%s for episode %sx%s of "%s"' \
% (scene_season, scene_episode, for_season, for_episode, show_obj.name) % (scene_season, scene_episode, for_season, for_episode, show_obj.name)
ep_args = {'show': indexerid, 'season': for_season, 'episode': for_episode} scene_args.update({'scene_season': scene_season, 'scene_episode': scene_episode})
scene_args = {'indexer_id': indexerid, 'indexer': indexer, 'season': for_season, 'episode': for_episode,
'sceneSeason': scene_season, 'sceneEpisode': scene_episode}
result = {'forSeason': for_season, 'forEpisode': for_episode, 'sceneSeason': None, 'sceneEpisode': None} result = {'forSeason': for_season, 'forEpisode': for_episode, 'sceneSeason': None, 'sceneEpisode': None}
else: else:
for_absolute = None if forAbsolute in [None, 'null', ''] else int(forAbsolute) for_absolute = None if for_absolute in [None, 'null', ''] else int(for_absolute)
scene_absolute = None if sceneAbsolute in [None, 'null', ''] else int(sceneAbsolute) scene_absolute = None if scene_absolute in [None, 'null', ''] else int(scene_absolute)
action_log = u'Set absolute scene numbering to %s for episode %s of "%s"' \ action_log = u'Set absolute scene numbering to %s for episode %sx%s of "%s"' \
% (scene_absolute, for_absolute, show_obj.name) % (scene_absolute, for_season, for_episode, show_obj.name)
ep_args = {'show': indexerid, 'absolute': for_absolute} ep_args.update({'absolute': for_absolute})
scene_args = {'indexer_id': indexerid, 'indexer': indexer, 'absolute_number': for_absolute, scene_args.update({'absolute_number': for_absolute, 'scene_absolute': scene_absolute, 'anime': True})
'sceneAbsolute': scene_absolute}
result = {'forAbsolute': for_absolute, 'sceneAbsolute': None} result = {'forAbsolute': for_absolute, 'sceneAbsolute': None}
if ep_args.get('absolute'): if ep_args.get('absolute'):
@ -735,18 +753,15 @@ def set_scene_numbering_helper(indexerid, indexer, forSeason=None, forEpisode=No
elif None is not ep_args['season'] and None is not ep_args['episode']: elif None is not ep_args['season'] and None is not ep_args['episode']:
ep_obj = show_obj.getEpisode(int(ep_args['season']), int(ep_args['episode'])) ep_obj = show_obj.getEpisode(int(ep_args['season']), int(ep_args['episode']))
else: else:
ep_obj = 'Invalid paramaters' ep_obj = 'Invalid parameters'
if ep_obj is None: result['success'] = None is not ep_obj and not isinstance(ep_obj, str)
ep_obj = "Episode couldn't be retrieved"
result['success'] = not isinstance(ep_obj, str)
if result['success']: if result['success']:
logger.log(action_log, logger.DEBUG) logger.log(action_log, logger.DEBUG)
set_scene_numbering(**scene_args) set_scene_numbering(**scene_args)
show_obj.flushEpisodes() show_obj.flushEpisodes()
else: else:
result['errorMessage'] = ep_obj result['errorMessage'] = "Episode couldn't be retrieved, invalid parameters"
if not show_obj.is_anime: if not show_obj.is_anime:
scene_numbering = get_scene_numbering(indexerid, indexer, for_season, for_episode) scene_numbering = get_scene_numbering(indexerid, indexer, for_season, for_episode)
@ -757,4 +772,4 @@ def set_scene_numbering_helper(indexerid, indexer, forSeason=None, forEpisode=No
if scene_numbering: if scene_numbering:
result['sceneAbsolute'] = scene_numbering result['sceneAbsolute'] = scene_numbering
return result return result

View file

@ -992,7 +992,7 @@ class TVShow(object):
if not self.tag: if not self.tag:
self.tag = 'Show List' self.tag = 'Show List'
logger.log('Loaded.. {: <9} {: <8} {}'.format( logger.log(u'Loaded.. {: <9} {: <8} {}'.format(
sickbeard.indexerApi(self.indexer).config.get('name') + ',', str(self.indexerid) + ',', self.name)) sickbeard.indexerApi(self.indexer).config.get('name') + ',', str(self.indexerid) + ',', self.name))
# Get IMDb_info from database # Get IMDb_info from database

View file

@ -2342,16 +2342,18 @@ class Home(MainHandler):
showObj.rls_require_words = rls_require_words.strip() showObj.rls_require_words = rls_require_words.strip()
# if we change location clear the db of episodes, change it, write to db, and rescan # if we change location clear the db of episodes, change it, write to db, and rescan
if os.path.normpath(showObj._location) != os.path.normpath(location): old_path = ek.ek(os.path.normpath, showObj._location)
logger.log(os.path.normpath(showObj._location) + ' != ' + os.path.normpath(location), logger.DEBUG) new_path = ek.ek(os.path.normpath, location)
if not ek.ek(os.path.isdir, location) and not sickbeard.CREATE_MISSING_SHOW_DIRS: if old_path != new_path:
errors.append('New location <tt>%s</tt> does not exist' % location) logger.log(u'%s != %s' % (old_path, new_path), logger.DEBUG)
if not ek.ek(os.path.isdir, new_path) and not sickbeard.CREATE_MISSING_SHOW_DIRS:
errors.append(u'New location <tt>%s</tt> does not exist' % new_path)
# don't bother if we're going to update anyway # don't bother if we're going to update anyway
elif not do_update: elif not do_update:
# change it # change it
try: try:
showObj.location = location showObj.location = new_path
try: try:
sickbeard.showQueueScheduler.action.refreshShow(showObj) # @UndefinedVariable sickbeard.showQueueScheduler.action.refreshShow(showObj) # @UndefinedVariable
except exceptions.CantRefreshException as e: except exceptions.CantRefreshException as e:
@ -2361,7 +2363,8 @@ class Home(MainHandler):
# rescan the episodes in the new folder # rescan the episodes in the new folder
except exceptions.NoNFOException: except exceptions.NoNFOException:
errors.append( errors.append(
"The folder at <tt>%s</tt> doesn't contain a tvshow.nfo - copy your files to that folder before you change the directory in SickGear." % location) u"The folder at <tt>%s</tt> doesn't contain a tvshow.nfo - "
u"copy your files to that folder before you change the directory in SickGear." % new_path)
# save it to the DB # save it to the DB
showObj.saveToDB() showObj.saveToDB()