1
0
mirror of https://github.com/moparisthebest/SickRage synced 2024-12-12 11:02:21 -05:00

Merge pull request #1322 from abeloin/patch-subtitle_flags

Fix subtitles display issues.
This commit is contained in:
Alexandre Beloin 2015-02-15 20:08:03 -05:00
commit 945e2b58db
4 changed files with 49 additions and 22 deletions

View File

@ -507,13 +507,15 @@
#if $sickbeard.USE_SUBTITLES and $show.subtitles: #if $sickbeard.USE_SUBTITLES and $show.subtitles:
<td class="col-subtitles" align="center"> <td class="col-subtitles" align="center">
#if $epResult["subtitles"]: #if $epResult["subtitles"]:
#for $sub_lang in subliminal.language.language_list([x.strip() for x in $epResult["subtitles"].split(',') if x != ""]): #for $sub_lang in subliminal.language.language_list([x.strip() for x in $epResult["subtitles"].split(',')] if x != ""):
#if sub_lang.alpha2 != "" #if sub_lang.alpha2 != ""
<img src="$sbRoot/images/flags/${sub_lang.alpha2}.png" width="16" height="11" alt="${sub_lang}" /> <img src="$sbRoot/images/flags/${sub_lang.alpha2}.png" width="16" height="11" alt="${sub_lang}" />
#end if #else
#end for <img src="$sbRoot/images/flags/unknown.png" width="16" height="11" alt="Unknown" />
#end if #end if
#end for
#end if
</td> </td>
#end if #end if

View File

@ -131,7 +131,11 @@
<td class="tvShow" width="35%"><a href="$sbRoot/home/displayShow?show=$hItem["showid"]#season-$hItem["season"]">$hItem["show_name"] - <%="S%02i" % int(hItem["season"])+"E%02i" % int(hItem["episode"]) %>#if "proper" in $hItem["resource"].lower() or "repack" in $hItem["resource"].lower() then ' <span class="quality Proper">Proper</span>' else ""#</a></td> <td class="tvShow" width="35%"><a href="$sbRoot/home/displayShow?show=$hItem["showid"]#season-$hItem["season"]">$hItem["show_name"] - <%="S%02i" % int(hItem["season"])+"E%02i" % int(hItem["episode"]) %>#if "proper" in $hItem["resource"].lower() or "repack" in $hItem["resource"].lower() then ' <span class="quality Proper">Proper</span>' else ""#</a></td>
<td align="center" #if $curStatus == SUBTITLED then 'class="subtitles_column"' else ''#> <td align="center" #if $curStatus == SUBTITLED then 'class="subtitles_column"' else ''#>
#if $curStatus == SUBTITLED: #if $curStatus == SUBTITLED:
<img width="16" height="11" style="vertical-align:middle;" src="$sbRoot/images/flags/<%= hItem["resource"][len(hItem["resource"])-6:len(hItem["resource"])-4]+'.png'%>"> #if $sickbeard.SUBTITLES_MULTI:
<img width="16" height="11" style="vertical-align:middle;" src="$sbRoot/images/flags/<%= hItem["resource"][len(hItem["resource"])-6:len(hItem["resource"])-4]+'.png'%>" onError="this.onerror=null;this.src='$sbRoot/images/flags/unknown.png';">
#else
<img width="16" height="11" style="vertical-align:middle;" src="$sbRoot/images/flags/unknown.png">
#end if
#end if #end if
<span style="cursor: help; vertical-align:middle;" title="$os.path.basename($hItem["resource"])">$statusStrings[$curStatus]</span> <span style="cursor: help; vertical-align:middle;" title="$os.path.basename($hItem["resource"])">$statusStrings[$curStatus]</span>
</td> </td>

View File

@ -14,9 +14,9 @@
$.each(subtitles,function(index, language){ $.each(subtitles,function(index, language){
if (language != "" && language != "und") { if (language != "" && language != "und") {
if (index != subtitles.length - 1) { if (index != subtitles.length - 1) {
subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/flags/"+language+".png", "alt": language, "width": 16, "height": 11}).css({'padding-right' : '6px','padding-bottom' : '4px'})); subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/flags/"+language+".png", "alt": language, "width": 16, "height": 11}));
} else { } else {
subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/flags/"+language+".png", "alt": language, "width": 16, "height": 11}).css({'padding-bottom' : '4px'})); subtitles_td.append($("<img/>").attr({"src": sbRoot+"/images/flags/"+language+".png", "alt": language, "width": 16, "height": 11}));
} }
} }
}); });

View File

@ -1390,6 +1390,7 @@ class TVEpisode(object):
self.episode), logger.DEBUG) self.episode), logger.DEBUG)
previous_subtitles = self.subtitles previous_subtitles = self.subtitles
added_subtitles = []
try: try:
need_languages = set(sickbeard.SUBTITLES_LANGUAGES) - set(self.subtitles) need_languages = set(sickbeard.SUBTITLES_LANGUAGES) - set(self.subtitles)
@ -1407,19 +1408,25 @@ class TVEpisode(object):
helpers.chmodAsParent(subs_new_path) helpers.chmodAsParent(subs_new_path)
for subtitle in subtitles.get(video): for subtitle in subtitles.get(video):
added_subtitles.append(subtitle.language.alpha2)
new_file_path = ek.ek(os.path.join, subs_new_path, os.path.basename(subtitle.path)) new_file_path = ek.ek(os.path.join, subs_new_path, os.path.basename(subtitle.path))
helpers.moveFile(subtitle.path, new_file_path) helpers.moveFile(subtitle.path, new_file_path)
helpers.chmodAsParent(new_file_path) helpers.chmodAsParent(new_file_path)
else: else:
for video in subtitles: for video in subtitles:
for subtitle in subtitles.get(video): for subtitle in subtitles.get(video):
added_subtitles.append(subtitle.language.alpha2)
helpers.chmodAsParent(subtitle.path) helpers.chmodAsParent(subtitle.path)
except Exception as e: except Exception as e:
logger.log("Error occurred when downloading subtitles: " + traceback.format_exc(), logger.ERROR) logger.log("Error occurred when downloading subtitles: " + traceback.format_exc(), logger.ERROR)
return return
self.refreshSubtitles() if sickbeard.SUBTITLES_MULTI:
self.refreshSubtitles()
else:
self.subtitles = added_subtitles
self.subtitles_searchcount = self.subtitles_searchcount + 1 if self.subtitles_searchcount else 1 # added the if because sometime it raise an error self.subtitles_searchcount = self.subtitles_searchcount + 1 if self.subtitles_searchcount else 1 # added the if because sometime it raise an error
self.subtitles_lastsearch = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") self.subtitles_lastsearch = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
self.saveToDB() self.saveToDB()
@ -1931,7 +1938,7 @@ class TVEpisode(object):
myDB = db.DBConnection() myDB = db.DBConnection()
rows = myDB.select( rows = myDB.select(
'SELECT episode_id FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?', 'SELECT episode_id, subtitles FROM tv_episodes WHERE showid = ? AND season = ? AND episode = ?',
[self.show.indexerid, self.season, self.episode]) [self.show.indexerid, self.season, self.episode])
epID = None epID = None
@ -1940,16 +1947,30 @@ class TVEpisode(object):
if epID: if epID:
# use a custom update method to get the data into the DB for existing records. # use a custom update method to get the data into the DB for existing records.
return [ # Multi or added subtitle or removed subtitles
"UPDATE tv_episodes SET indexerid = ?, indexer = ?, name = ?, description = ?, subtitles = ?, " if sickbeard.SUBTITLES_MULTI or not rows[0]['subtitles'] or not self.subtitles:
"subtitles_searchcount = ?, subtitles_lastsearch = ?, airdate = ?, hasnfo = ?, hastbn = ?, status = ?, " return [
"location = ?, file_size = ?, release_name = ?, is_proper = ?, showid = ?, season = ?, episode = ?, " "UPDATE tv_episodes SET indexerid = ?, indexer = ?, name = ?, description = ?, subtitles = ?, "
"absolute_number = ?, version = ?, release_group = ? WHERE episode_id = ?", "subtitles_searchcount = ?, subtitles_lastsearch = ?, airdate = ?, hasnfo = ?, hastbn = ?, status = ?, "
[self.indexerid, self.indexer, self.name, self.description, ",".join([sub for sub in self.subtitles]), "location = ?, file_size = ?, release_name = ?, is_proper = ?, showid = ?, season = ?, episode = ?, "
self.subtitles_searchcount, self.subtitles_lastsearch, self.airdate.toordinal(), self.hasnfo, "absolute_number = ?, version = ?, release_group = ? WHERE episode_id = ?",
self.hastbn, [self.indexerid, self.indexer, self.name, self.description, ",".join([sub for sub in self.subtitles]),
self.status, self.location, self.file_size, self.release_name, self.is_proper, self.show.indexerid, self.subtitles_searchcount, self.subtitles_lastsearch, self.airdate.toordinal(), self.hasnfo,
self.season, self.episode, self.absolute_number, self.version, self.release_group, epID]] self.hastbn,
self.status, self.location, self.file_size, self.release_name, self.is_proper, self.show.indexerid,
self.season, self.episode, self.absolute_number, self.version, self.release_group, epID]]
else:
# Don't update the subtitle language when the srt file doesn't contain the alpha2 code, keep value from subliminal
return [
"UPDATE tv_episodes SET indexerid = ?, indexer = ?, name = ?, description = ?, "
"subtitles_searchcount = ?, subtitles_lastsearch = ?, airdate = ?, hasnfo = ?, hastbn = ?, status = ?, "
"location = ?, file_size = ?, release_name = ?, is_proper = ?, showid = ?, season = ?, episode = ?, "
"absolute_number = ?, version = ?, release_group = ? WHERE episode_id = ?",
[self.indexerid, self.indexer, self.name, self.description,
self.subtitles_searchcount, self.subtitles_lastsearch, self.airdate.toordinal(), self.hasnfo,
self.hastbn,
self.status, self.location, self.file_size, self.release_name, self.is_proper, self.show.indexerid,
self.season, self.episode, self.absolute_number, self.version, self.release_group, epID]]
else: else:
# use a custom insert method to get the data into the DB. # use a custom insert method to get the data into the DB.
return [ return [