Commit ae336d85 authored by Dustyn Gibson's avatar Dustyn Gibson
Browse files

More work on subtitles

parent b99cd7fd
......@@ -8,6 +8,7 @@
#import datetime
#import urllib
#import ntpath
#import babelfish
#set global $title=$show.name
##set global $header = '<a></a>' %
......@@ -579,7 +580,7 @@
</td>
<td class="col-subtitles" align="center">
#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 babelfish.LANGUAGE_MATRIX([x.strip() for x in $epResult["subtitles"].split(',') if x != ""]):
#if sub_lang.alpha2 != ""
<img src="$sbRoot/images/flags/${sub_lang.alpha2}.png" width="16" height="11" alt="${sub_lang}" />
#else
......
#import sickbeard
#from lib import subliminal
#from lib import babelfish
#import datetime
#from sickbeard import common
#set global $title="Episode Overview"
......@@ -17,7 +18,7 @@
<h1 class="title">$title</h1>
#end if
#if $whichSubs:
#set subsLanguage = $subliminal.language.Language($whichSubs) if not $whichSubs == 'all' else 'All'
#set subsLanguage = $babelfish.language.Language($whichSubs) if not $whichSubs == 'all' else 'All'
#end if
#if not $whichSubs or ($whichSubs and not $ep_counts):
......@@ -29,7 +30,7 @@
<form action="$sbRoot/manage/subtitleMissed" method="get">
Manage episodes without <select name="whichSubs" class="form-control form-control-inline input-sm">
<option value="all">All</option>
#for $sub_lang in $subliminal.language.language_list($sickbeard.SUBTITLES_LANGUAGES):
#for $sub_lang in $babelfish.LANGUAGE_MATRIX:
<option value="$sub_lang.alpha2">$sub_lang</option>
#end for
</select>
......
......@@ -41,6 +41,8 @@ import operator
import sickbeard
import subliminal
import babelfish
import adba
from lib import requests
import certifi
......@@ -516,7 +518,7 @@ def rename_ep_file(cur_path, new_path, old_path_length=0):
# Check if the language extracted from filename is a valid language
try:
language = subliminal.language.Language(sublang, strict=True)
language = babelfish.language.Language(sublang, strict=True)
cur_file_ext = '.' + sublang + cur_file_ext
except ValueError:
pass
......
......@@ -36,12 +36,12 @@ def sortedServiceList():
newList = []
# add all services in the priority list, in order
# curIndex = 0
# for curService in sickbeard.SUBTITLES_SERVICES_LIST:
# if curService in servicesMapping:
# curServiceDict = {'id': curService, 'image': curService+'.png', 'name': curService, 'enabled': sickbeard.SUBTITLES_SERVICES_ENABLED[curIndex] == 1, 'url': __import__(servicesMapping[curService], globals=globals(), locals=locals(), fromlist=['Service'], level=-1).Service.server}
# newList.append(curServiceDict)
# curIndex += 1
curIndex = 0
for curService in sickbeard.SUBTITLES_SERVICES_LIST:
if curService in servicesMapping:
curServiceDict = {'id': curService, 'image': curService+'.png', 'name': curService, 'enabled': sickbeard.SUBTITLES_SERVICES_ENABLED[curIndex] == 1, 'api_based': True, 'url': 'null'}
newList.append(curServiceDict)
curIndex += 1
# add any services that are missing from that list
for curService in servicesMapping.keys():
......
......@@ -66,6 +66,8 @@ from common import NAMING_DUPLICATE, NAMING_EXTEND, NAMING_LIMITED_EXTEND, NAMIN
import shutil
import lib.shutil_custom
import babelfish
shutil.copyfile = lib.shutil_custom.copyfile_custom
......@@ -1478,7 +1480,7 @@ class TVEpisode(object):
newsubtitles = set(self.subtitles).difference(set(previous_subtitles))
if newsubtitles:
subtitleList = ", ".join(subliminal.language.Language(x).name for x in newsubtitles)
subtitleList = ", ".join(babelfish.language.Language(x).name for x in newsubtitles)
logger.log(str(self.show.indexerid) + u": Downloaded " + subtitleList + " subtitles for episode " + str(
self.season) + "x" + str(self.episode), logger.DEBUG)
......
......@@ -46,6 +46,7 @@ except ImportError:
from lib import simplejson as json
from lib import subliminal
import babelfish
from tornado.web import RequestHandler
......@@ -1082,8 +1083,8 @@ class CMD_SubtitleSearch(ApiCall):
# return the correct json value
if previous_subtitles != epObj.subtitles:
status = 'New subtitles downloaded: %s' % ' '.join([
"<img src='" + sickbeard.WEB_ROOT + "/images/flags/" + subliminal.language.Language(
x).alpha2 + ".png' alt='" + subliminal.language.Language(x).name + "'/>" for x in
"<img src='" + sickbeard.WEB_ROOT + "/images/flags/" + babelfish.language.Language(
x).alpha2 + ".png' alt='" + babelfish.language.Language(x).name + "'/>" for x in
sorted(list(set(epObj.subtitles).difference(previous_subtitles)))])
response = _responds(RESULT_SUCCESS, msg='New subtitles found')
else:
......
......@@ -58,6 +58,7 @@ from lib import adba, subliminal
from lib.trakt import TraktAPI
from lib.trakt.exceptions import traktException
from versionChecker import CheckVersion
import babelfish
try:
import json
......@@ -2012,7 +2013,7 @@ class Home(WebRoot):
return json.dumps({'result': 'failure'})
# try do download subtitles for that episode
previous_subtitles = set(subliminal.language.Language(x) for x in ep_obj.subtitles)
previous_subtitles = set(babelfish.language.Language(x) for x in ep_obj.subtitles)
try:
ep_obj.subtitles = set(x.language for x in ep_obj.downloadSubtitles().values()[0])
except:
......@@ -2903,7 +2904,7 @@ class Manage(Home, WebRoot):
result[cur_season][cur_episode]["name"] = cur_result["name"]
result[cur_season][cur_episode]["subtitles"] = ",".join(
subliminal.language.Language(subtitle).alpha2 for subtitle in cur_result["subtitles"].split(',')) if not \
babelfish.language.Language(subtitle).alpha2 for subtitle in cur_result["subtitles"].split(',')) if not \
cur_result["subtitles"] == '' else ''
return json.dumps(result)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment