Skip to content

Commit

Permalink
2.1.9
Browse files Browse the repository at this point in the history
- fixed: addic7ed service changes due to the changed website layout
  • Loading branch information
Zeljko Ametovic committed Dec 1, 2010
1 parent a6e41b8 commit 8d866f2
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 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.1.8"
version="2.1.9"
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.1.9
- fixed: addic7ed service changes due to the changed website layout

2.1.8
- fixed: indent error while cleaning up :(

Expand Down
30 changes: 22 additions & 8 deletions script.xbmc.subtitles/resources/lib/services/Addic7ed/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,23 @@
self_release_pattern = re.compile(" \nVersion (.+), ([0-9]+).([0-9])+ MBs")

def compare_columns(b,a):
return cmp( a["sync"], b["sync"] ) or cmp( b["language_name"], a["language_name"] )
return cmp( a["sync"], b["sync"] ) or cmp( b["language_name"], a["language_name"] )

def get_url(url):
req_headers = {
'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.13 (KHTML, like Gecko) Chrome/0.A.B.C Safari/525.13',
'Referer': 'http://www.addic7ed.com'}
request = urllib2.Request(url, headers=req_headers)
opener = urllib2.build_opener()
response = opener.open(request)

contents = response.read()
return contents

def query_TvShow(name, season, episode, file_original_path, langs):
sublinks = []
name = name.lower().replace(" ", "_").replace("$#*!","shit") #need this for $#*! My Dad Says
searchurl = "%s/serie/%s/%s/%s/%s" %(self_host, name, season, episode, name)
searchurl = "%s/serie/%s/%s/%s/addic7ed" %(self_host, name, season, episode)
socket.setdefaulttimeout(3)
page = urllib2.urlopen(searchurl)
content = page.read()
Expand All @@ -25,22 +36,24 @@ def query_TvShow(name, season, episode, file_original_path, langs):
for subs in soup("td", {"class":"NewsTitle", "colspan" : "3"}):
try:
langs_html = subs.findNext("td", {"class" : "language"})
fullLanguage = str(langs_html).split('class="language">')[1].split('&nbsp;<a')[0].replace("\n","")
subteams = self_release_pattern.match(str(subs.contents[1])).groups()[0].lower()
file_name = os.path.basename(file_original_path).lower()
if (file_name.find(str(subteams))) > -1:
hashed = True
else:
hashed = False
try:
lang = toOpenSubtitles_two(langs_html.string.strip())
lang = toOpenSubtitles_two(fullLanguage)
except:
lang = ""
statusTD = langs_html.findNext("td")
status = statusTD.find("strong").string.strip()
link = "%s%s"%(self_host,statusTD.findNext("td").find("a")["href"])
if status == "Completed" and (lang in langs) :
sublinks.append({'filename':"%s.S%.2dE%.2d-%s" %(name.replace("_", ".").title(), int(season), int(episode),subteams ),'link':link,'language_name':langs_html.string.strip(),'language_id':lang,'language_flag':"flags/%s.gif" % (lang,),'movie':"movie","ID":"subtitle_id","rating":"0","format":"srt","sync":hashed})
sublinks.append({'filename':"%s.S%.2dE%.2d-%s" %(name.replace("_", ".").title(), int(season), int(episode),subteams ),'link':link,'language_name':fullLanguage,'language_id':lang,'language_flag':"flags/%s.gif" % (lang,),'movie':"movie","ID":"subtitle_id","rating":"0","format":"srt","sync":hashed})
except:
print "Error"
pass
return sublinks

Expand All @@ -56,21 +69,22 @@ def query_Film(name, file_original_path,year, langs):
for subs in soup("td", {"class":"NewsTitle", "colspan" : "3"}):
try:
langs_html = subs.findNext("td", {"class" : "language"})
fullLanguage = str(langs_html).split('class="language">')[1].split('&nbsp;<a')[0].replace("\n","")
subteams = self_release_pattern.match(str(subs.contents[1])).groups()[0].lower()
file_name = os.path.basename(file_original_path).lower()
if (file_name.find(str(subteams))) > -1:
hashed = True
else:
hashed = False
try:
lang = toOpenSubtitles_two(langs_html.string.strip())
lang = toOpenSubtitles_two(fullLanguage)
except:
lang = ""
statusTD = langs_html.findNext("td")
status = statusTD.find("strong").string.strip()
link = "%s%s"%(self_host,statusTD.findNext("td").find("a")["href"])
if status == "Completed" and (lang in langs) :
sublinks.append({'filename':"%s-%s" %(name.replace("_", ".").title(),subteams ),'link':link,'language_name':langs_html.string.strip(),'language_id':lang,'language_flag':"flags/%s.gif" % (lang,),'movie':"movie","ID":"subtitle_id","rating":"0","format":"srt","sync":hashed})
sublinks.append({'filename':"%s-%s" %(name.replace("_", ".").title(),subteams ),'link':link,'language_name':fullLanguage,'language_id':lang,'language_flag':"flags/%s.gif" % (lang,),'movie':"movie","ID":"subtitle_id","rating":"0","format":"srt","sync":hashed})
except:
pass
return sublinks
Expand Down Expand Up @@ -99,10 +113,10 @@ def download_subtitles (subtitles_list, pos, zip_subs, tmp_sub_dir, sub_folder,
url = subtitles_list[pos][ "link" ]
file = os.path.join(tmp_sub_dir, "adic7ed.srt")

f = urllib2.urlopen(url)
f = get_url(url)

local_file_handle = open(file, "w" + "b")
local_file_handle.write(f.read())
local_file_handle.write(f)
local_file_handle.close()

language = subtitles_list[pos][ "language_name" ]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8d866f2

Please sign in to comment.