Skip to content

Commit

Permalink
2.2.4
Browse files Browse the repository at this point in the history
- fixed: Titulky service login, thx to Libor
  • Loading branch information
amet committed Jan 23, 2011
1 parent f08c2ea commit 5b10bfd
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 32 deletions.
2 changes: 1 addition & 1 deletion script.xbmc.subtitles/addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.xbmc.subtitles"
name="XBMC Subtitles"
version="2.2.3"
version="2.2.4"
provider-name="Amet">
<requires>
<import addon="xbmc.python" version="1.0"/>
Expand Down
3 changes: 3 additions & 0 deletions script.xbmc.subtitles/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2.2.4
- fixed: Titulky service login, thx to Libor

2.2.3
- fixed: Bierdopje needs a single quote changed to two single quotes (Grey's Anatomy -> Grey''s Anatomy) otherwise it couldn't find a show-id, thx mr_blobby
- fixed: Hungarian translation, thanks alanwww1.
Expand Down
5 changes: 4 additions & 1 deletion script.xbmc.subtitles/resources/language/Czech/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
<string id="757">Server vyžaduje opsat kontrolní kód z obrázku</string>
<string id="758">Kontrolní kód se objeví v oznamovací oblasti</string>
<string id="759">Vložte kontrolní kód</string>
<string id="760">Available Services</string>
<string id="760">Dostupné služby</string>
<string id="761">Pro stažení těchto titulků je třeba přihlášení,[CR]nastavte prosím přihlašovací údaje</string>

<!-- Script Settings -->

Expand All @@ -50,6 +51,8 @@
<string id="30125">Vypnout hledání pomocí hashe</string>
<string id="30126">- Itasa jméno</string>
<string id="30127">- Itasa heslo</string>
<string id="30128">- Titulky jméno</string>
<string id="30129">- Titulky heslo</string>

<!-- Languages -->

Expand Down
3 changes: 3 additions & 0 deletions script.xbmc.subtitles/resources/language/English/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<string id="758">Please take look at notification area</string>
<string id="759">Enter code of image in notification area</string>
<string id="760">Available Services</string>
<string id="761">You must be logged in to download these subtitles,[CR]verify your settings at the addon Configuration</string>

<!-- Script Settings -->

Expand All @@ -50,6 +51,8 @@
<string id="30125">Disable hash search</string>
<string id="30126">- Itasa Username</string>
<string id="30127">- Itasa Password</string>
<string id="30128">- Titulky Username</string>
<string id="30129">- Titulky Password</string>

<!-- Languages -->

Expand Down
68 changes: 38 additions & 30 deletions script.xbmc.subtitles/resources/lib/services/Titulky/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
_ = sys.modules[ "__main__" ].__language__
__scriptname__ = sys.modules[ "__main__" ].__scriptname__
__cwd__ = sys.modules[ "__main__" ].__cwd__

__settings__ = sys.modules[ "__main__" ].__settings__
"""
<tr class="row2">
<td><a href="Pulp-Fiction-118518.htm" >Pulp Fiction</a></td>
Expand Down Expand Up @@ -49,17 +49,6 @@ def search_subtitles( file_original_path, title, tvshow, year, season, episode,
if br_index > -1:
title = title[:br_index]
title = title.strip()
# print 'path '+file_original_path
# print 'title '+title
# print 'tvshow '+tvshow
# print 'year '+year
# print 'season '+season
# print 'episode'+episode
# print 'set_temp '+str(set_temp)
# print 'rar '+str(rar)
# print 'lang1 '+lang1
# print 'lang2 '+lang2
# print 'lang3 '+lang3
session_id = "0"
client = TitulkyClient()
subtitles_list = client.search_subtitles( file_original_path, title, tvshow, year, season, episode, set_temp, rar, lang1, lang2, lang3 )
Expand All @@ -70,14 +59,18 @@ def search_subtitles( file_original_path, title, tvshow, year, season, episode,
def download_subtitles (subtitles_list, pos, zip_subs, tmp_sub_dir, sub_folder, session_id): #standard input

subtitle_id = subtitles_list[pos][ 'ID' ]
# print pos
# print zip_subs
# print tmp_sub_dir
# print sub_folder
# print session_id
# print subtitle_id

client = TitulkyClient()
username = __settings__.getSetting( "Titulkyuser" )
password = __settings__.getSetting( "Titulkypass" )
if password == '' or username == '':
log(__name__,'Credentials to Titulky.com not provided')
else:
if client.login(username,password) == False:
log(__name__,'Login to Titulky.com failed. Check your username/password at the addon configuration')
dialog = xbmcgui.Dialog()
dialog.ok(__scriptname__,_( 756 ))
return True,subtitles_list[pos]['language_name'], ""
log(__name__,'Login successfull')
log(__name__,'Get page with subtitle (id=%s)'%(subtitle_id))
content = client.get_subtitle_page(subtitle_id)
control_img = client.get_control_image(content)
Expand All @@ -92,7 +85,7 @@ def download_subtitles (subtitles_list, pos, zip_subs, tmp_sub_dir, sub_folder,
dialog = xbmcgui.Dialog()
dialog.ok(__scriptname__,_( 757 ),_( 758 ))
log(__name__,'Notifying user for 10s')
xbmc.executebuiltin("XBMC.Notification(%s,%s,10000,%s)" % (__scriptname__,'',os.path.join(tmp_sub_dir,'image.png')))
xbmc.executebuiltin("XBMC.Notification(%s,%s,10000,%s)" % (__scriptname__,'',os.path.join(tmp_sub_dir,'image.png')))
kb = xbmc.Keyboard('',_( 759 ),False)
kb.doModal()
if kb.isConfirmed():
Expand All @@ -107,6 +100,12 @@ def download_subtitles (subtitles_list, pos, zip_subs, tmp_sub_dir, sub_folder,
log(__name__,'Control text not confirmed, returning in error')
return True,subtitles_list[pos]['language_name'], ""
wait_time = client.get_waittime(content)
cannot_download = client.get_cannot_download_error(content)
if not None == cannot_download:
log(__name__,'Subtitles cannot be downloaded, user needs to login')
dialog = xbmcgui.Dialog()
dialog.ok(__scriptname__,_( 761 ))
return True,subtitles_list[pos]['language_name'], ""
link = client.get_link(content)
log(__name__,'Got the link, wait %i seconds before download' % (wait_time))
delay = wait_time
Expand All @@ -116,6 +115,7 @@ def download_subtitles (subtitles_list, pos, zip_subs, tmp_sub_dir, sub_folder,
xbmc.executebuiltin("XBMC.Notification(%s,%s,1000,%s)" % (__scriptname__,line2,icon))
delay -= 1
time.sleep(1)

log(__name__,'Downloading subtitle zip')
data = client.get_file(link)
log(__name__,'Saving to file %s' % zip_subs)
Expand Down Expand Up @@ -145,16 +145,22 @@ def get2DigitStr(number):
def lang2_opensubtitles(lang):
lang = lang_titulky2xbmclang(lang)
return toOpenSubtitles_two(lang)

class TitulkyClient(object):

def __init__(self):
self.server_url = 'http://www.titulky.com'
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookielib.LWPCookieJar()))
opener.version = 'User-Agent=Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)'
urllib2.install_opener(opener)

def search_subtitles(self, file_original_path, title, tvshow, year, season, episode, set_temp, rar, lang1, lang2, lang3 ):
def login(self,username,password):
log(__name__,'Logging in to Titulky.com')
login_postdata = urllib.urlencode({'Login': username, 'Password': password, 'foreverlog': '1','Detail2':''} )
request = urllib2.Request(self.server_url + '/index.php',login_postdata)
response = urllib2.urlopen(request).read()
log(__name__,'Got response')
return not response.find('BadLogin')>-1
def search_subtitles(self, file_original_path, title, tvshow, year, season, episode, set_temp, rar, lang1, lang2, lang3 ):
url = self.server_url+'/index.php?'+urllib.urlencode({'Fulltext':title,'FindUser':''})
if not (tvshow == None or tvshow == ''):
title2 = tvshow+' '+get_episode_season(episode,season)
Expand All @@ -164,15 +170,14 @@ def search_subtitles(self, file_original_path, title, tvshow, year, season, epis
file_size='%.2f' % (float(os.path.getsize(file_original_path))/(1024*1024))
except:
file_size=''
print file_size
log(__name__,'Opening %s' % (url))
response = urllib2.urlopen(req)
content = response.read()
response.close()
log(__name__,'Done')
subtitles_list = []
max_downloads=1
for matches in re.finditer(subtitle_pattern, content, re.IGNORECASE | re.DOTALL):
for matches in re.finditer(subtitle_pattern, content, re.IGNORECASE | re.DOTALL):
# print matches.group('id') +' ' +matches.group('title')+' '+ str(matches.group('sync'))+' '+ matches.group('tvshow')+' '+ matches.group('year')+' '+ matches.group('downloads')+' '+ matches.group('lang')+' '+ matches.group('cds')+' '+matches.group('size')
file_name = matches.group('sync')
if file_name == None: # if no sync info is found, just use title instead of None
Expand Down Expand Up @@ -200,18 +205,21 @@ def search_subtitles(self, file_original_path, title, tvshow, year, season, epis
for subtitle in subtitles_list:
subtitle['rating'] = str((subtitle['downloads']*10/max_downloads))
return subtitles_list

def get_cannot_download_error(self,content):
if content.find('CHYBA') > -1:
return True

def get_waittime(self,content):
for matches in re.finditer(countdown_pattern, content, re.IGNORECASE | re.DOTALL):
return int(matches.group(1))

def get_link(self,content):
for matches in re.finditer(sublink_pattern, content, re.IGNORECASE | re.DOTALL):
return str(matches.group(1))
return str(matches.group(1))

def _get_session_id(self,content):
for matches in re.finditer(session_id_pattern, content, re.IGNORECASE | re.DOTALL):
return str(matches.group(1))
return str(matches.group(1))

def get_control_image(self,content):
for matches in re.finditer(control_image_pattern, content, re.IGNORECASE | re.DOTALL):
Expand Down Expand Up @@ -250,4 +258,4 @@ def get_subtitle_page(self,id):
log(__name__,'Done')
response.close()
return content

2 changes: 2 additions & 0 deletions script.xbmc.subtitles/resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<setting id="LTVpass" type="text" option = "hidden" visible= "eq(-2,true)" enable="eq(-2,true)" label="30124" default=""/>
<setting id="Titlovi" type="bool" label="Titlovi.com" default="false"/>
<setting id="Titulky" type="bool" label="Titulky.com (Czech and Slovak subs only)" default="false"/>
<setting id="Titulkyuser" type="text" visible= "eq(-1,true)" enable="eq(-1,true)" label="30128" default=""/>
<setting id="Titulkypass" type="text" option ="hidden" visible= "eq(-2,true)" enable="eq(-2,true)" label="30129" default=""/>
<setting id="Subdivx" type="bool" label="Subdivx.com (Spanish subs only)" default="false"/>
<setting id="Addic7ed" type="bool" label="Addic7ed.com" default="false"/>
<setting id="Swesub" type="bool" label="Swesub.nu" default="false"/>
Expand Down

0 comments on commit 5b10bfd

Please sign in to comment.