mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 05:33:37 +00:00
Fix getting XEM absolute numbers for show.
Fix IMDb info load for redirected ids. Fix flags on displayShow (under Linux).
This commit is contained in:
parent
0b2b3f35df
commit
41a0cea90a
4 changed files with 35 additions and 13 deletions
|
@ -233,7 +233,7 @@
|
||||||
<span class="space-right">#echo ($startyear, 'Unknown')[None is $startyear]#</span>
|
<span class="space-right">#echo ($startyear, 'Unknown')[None is $startyear]#</span>
|
||||||
#if $flags
|
#if $flags
|
||||||
#for $country in $show.imdb_info['country_codes'].split('|')
|
#for $country in $show.imdb_info['country_codes'].split('|')
|
||||||
<img class="flag space-right" src="$sbRoot/images/flags/${$country}.png" width="16" height="11" />
|
<img class="flag space-right" src="$sbRoot/images/flags/${$country.lower()}.png" width="16" height="11" />
|
||||||
#end for
|
#end for
|
||||||
#end if
|
#end if
|
||||||
</span>
|
</span>
|
||||||
|
|
|
@ -65,6 +65,7 @@
|
||||||
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 = 0 if $ep['absolute_number'] not in $xem_absolute_numbering else $xem_absolute_numbering[$ep['absolute_number']]
|
#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"
|
||||||
|
|
|
@ -83,7 +83,7 @@ def find_scene_numbering(indexer_id, indexer, season, episode):
|
||||||
return int(rows[0]['scene_season']), int(rows[0]['scene_episode'])
|
return int(rows[0]['scene_season']), int(rows[0]['scene_episode'])
|
||||||
|
|
||||||
|
|
||||||
def get_scene_absolute_numbering(indexer_id, indexer, absolute_number, fallback_to_xem=True):
|
def get_scene_absolute_numbering(indexer_id, indexer, absolute_number, season, episode, fallback_to_xem=True):
|
||||||
"""
|
"""
|
||||||
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
|
||||||
|
@ -110,7 +110,7 @@ def get_scene_absolute_numbering(indexer_id, indexer, absolute_number, fallback_
|
||||||
return result
|
return result
|
||||||
else:
|
else:
|
||||||
if fallback_to_xem:
|
if fallback_to_xem:
|
||||||
xem_result = find_xem_absolute_numbering(indexer_id, indexer, absolute_number)
|
xem_result = find_xem_absolute_numbering(indexer_id, indexer, absolute_number, season, episode)
|
||||||
if xem_result:
|
if xem_result:
|
||||||
return xem_result
|
return xem_result
|
||||||
return absolute_number
|
return absolute_number
|
||||||
|
@ -247,7 +247,7 @@ def find_xem_numbering(indexer_id, indexer, season, episode):
|
||||||
return int(rows[0]['scene_season']), int(rows[0]['scene_episode'])
|
return int(rows[0]['scene_season']), int(rows[0]['scene_episode'])
|
||||||
|
|
||||||
|
|
||||||
def find_xem_absolute_numbering(indexer_id, indexer, absolute_number):
|
def find_xem_absolute_numbering(indexer_id, indexer, absolute_number, season, episode):
|
||||||
"""
|
"""
|
||||||
Returns the scene numbering, as retrieved from xem.
|
Returns the scene numbering, as retrieved from xem.
|
||||||
Refreshes/Loads as needed.
|
Refreshes/Loads as needed.
|
||||||
|
@ -266,8 +266,8 @@ def find_xem_absolute_numbering(indexer_id, indexer, absolute_number):
|
||||||
|
|
||||||
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 absolute_number = ? 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, absolute_number])
|
[indexer, indexer_id, season, episode])
|
||||||
|
|
||||||
if rows:
|
if rows:
|
||||||
return int(rows[0]['scene_absolute_number'])
|
return int(rows[0]['scene_absolute_number'])
|
||||||
|
@ -437,14 +437,15 @@ def get_xem_absolute_numbering_for_show(indexer_id, indexer):
|
||||||
result = {}
|
result = {}
|
||||||
my_db = db.DBConnection()
|
my_db = db.DBConnection()
|
||||||
rows = my_db.select(
|
rows = my_db.select(
|
||||||
'SELECT absolute_number, scene_absolute_number FROM tv_episodes WHERE indexer = ? and showid = ? and scene_absolute_number != 0 ORDER BY absolute_number',
|
'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])
|
[indexer, indexer_id])
|
||||||
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
absolute_number = int(row['absolute_number'])
|
season = int(row['season'])
|
||||||
|
episode = int(row['episode'])
|
||||||
scene_absolute_number = int(row['scene_absolute_number'])
|
scene_absolute_number = int(row['scene_absolute_number'])
|
||||||
|
|
||||||
result[absolute_number] = scene_absolute_number
|
result[(season, episode)] = scene_absolute_number
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -752,7 +753,7 @@ def set_scene_numbering_helper(indexerid, indexer, forSeason=None, forEpisode=No
|
||||||
if scene_numbering:
|
if scene_numbering:
|
||||||
(result['sceneSeason'], result['sceneEpisode']) = scene_numbering
|
(result['sceneSeason'], result['sceneEpisode']) = scene_numbering
|
||||||
else:
|
else:
|
||||||
scene_numbering = get_scene_absolute_numbering(indexerid, indexer, for_absolute)
|
scene_numbering = get_scene_absolute_numbering(indexerid, indexer, for_absolute, for_season, for_episode)
|
||||||
if scene_numbering:
|
if scene_numbering:
|
||||||
result['sceneAbsolute'] = scene_numbering
|
result['sceneAbsolute'] = scene_numbering
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import re
|
||||||
import glob
|
import glob
|
||||||
import stat
|
import stat
|
||||||
import traceback
|
import traceback
|
||||||
|
import requests
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
import sickbeard
|
import sickbeard
|
||||||
|
@ -1077,6 +1078,17 @@ class TVShow(object):
|
||||||
logger.log('Error loading IMDb info: %s' % ex(e), logger.ERROR)
|
logger.log('Error loading IMDb info: %s' % ex(e), logger.ERROR)
|
||||||
logger.log('%s' % traceback.format_exc(), logger.ERROR)
|
logger.log('%s' % traceback.format_exc(), logger.ERROR)
|
||||||
|
|
||||||
|
def check_imdb_redirect(self, imdb_id):
|
||||||
|
page_url = 'https://www.imdb.com/title/{0}/'.format(imdb_id)
|
||||||
|
try:
|
||||||
|
response = requests.head(page_url, allow_redirects=True)
|
||||||
|
if response.history and any(h for h in response.history if h.status_code == 301):
|
||||||
|
return re.search(r'(tt\d{7})', response.url, flags=re.I).group(1)
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
except (StandardError, Exception):
|
||||||
|
return None
|
||||||
|
|
||||||
def _get_imdb_info(self):
|
def _get_imdb_info(self):
|
||||||
|
|
||||||
if not self.imdbid and self.ids.get(indexermapper.INDEXER_IMDB, {'id': 0}).get('id', 0) <= 0:
|
if not self.imdbid and self.ids.get(indexermapper.INDEXER_IMDB, {'id': 0}).get('id', 0) <= 0:
|
||||||
|
@ -1099,6 +1111,11 @@ class TVShow(object):
|
||||||
imdb_certificates = None
|
imdb_certificates = None
|
||||||
try:
|
try:
|
||||||
imdb_id = str(self.imdbid or 'tt%07d' % self.ids[indexermapper.INDEXER_IMDB]['id'])
|
imdb_id = str(self.imdbid or 'tt%07d' % self.ids[indexermapper.INDEXER_IMDB]['id'])
|
||||||
|
redirect_check = self.check_imdb_redirect(imdb_id)
|
||||||
|
if redirect_check:
|
||||||
|
self._imdbid = redirect_check
|
||||||
|
imdb_id = redirect_check
|
||||||
|
imdb_info['imdb_id'] = self.imdbid
|
||||||
i = imdbpie.Imdb(exclude_episodes=True)
|
i = imdbpie.Imdb(exclude_episodes=True)
|
||||||
if not re.search(r'tt\d{7}', imdb_id, flags=re.I):
|
if not re.search(r'tt\d{7}', imdb_id, flags=re.I):
|
||||||
logger.log('Not a valid imdbid: %s for show: %s' % (imdb_id, self.name), logger.WARNING)
|
logger.log('Not a valid imdbid: %s for show: %s' % (imdb_id, self.name), logger.WARNING)
|
||||||
|
@ -1914,7 +1931,8 @@ class TVEpisode(object):
|
||||||
self.scene_absolute_number = sickbeard.scene_numbering.get_scene_absolute_numbering(
|
self.scene_absolute_number = sickbeard.scene_numbering.get_scene_absolute_numbering(
|
||||||
self.show.indexerid,
|
self.show.indexerid,
|
||||||
self.show.indexer,
|
self.show.indexer,
|
||||||
self.absolute_number
|
absolute_number=self.absolute_number,
|
||||||
|
season=self.season, episode=episode
|
||||||
)
|
)
|
||||||
|
|
||||||
if self.scene_season == 0 or self.scene_episode == 0:
|
if self.scene_season == 0 or self.scene_episode == 0:
|
||||||
|
@ -2008,7 +2026,8 @@ class TVEpisode(object):
|
||||||
self.scene_absolute_number = sickbeard.scene_numbering.get_scene_absolute_numbering(
|
self.scene_absolute_number = sickbeard.scene_numbering.get_scene_absolute_numbering(
|
||||||
self.show.indexerid,
|
self.show.indexerid,
|
||||||
self.show.indexer,
|
self.show.indexer,
|
||||||
self.absolute_number
|
absolute_number=self.absolute_number,
|
||||||
|
season=self.season, episode=self.episode
|
||||||
)
|
)
|
||||||
|
|
||||||
self.scene_season, self.scene_episode = sickbeard.scene_numbering.get_scene_numbering(
|
self.scene_season, self.scene_episode = sickbeard.scene_numbering.get_scene_numbering(
|
||||||
|
@ -2175,7 +2194,8 @@ class TVEpisode(object):
|
||||||
self.scene_absolute_number = sickbeard.scene_numbering.get_scene_absolute_numbering(
|
self.scene_absolute_number = sickbeard.scene_numbering.get_scene_absolute_numbering(
|
||||||
self.show.indexerid,
|
self.show.indexerid,
|
||||||
self.show.indexer,
|
self.show.indexer,
|
||||||
self.absolute_number
|
absolute_number=self.absolute_number,
|
||||||
|
season=self.season, episode=self.episode
|
||||||
)
|
)
|
||||||
|
|
||||||
self.scene_season, self.scene_episode = sickbeard.scene_numbering.get_scene_numbering(
|
self.scene_season, self.scene_episode = sickbeard.scene_numbering.get_scene_numbering(
|
||||||
|
|
Loading…
Reference in a new issue