Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix : parsing err when only 1 SYNC subtitle exists #214

Open
wants to merge 2 commits into
base: frodo
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 41 additions & 24 deletions script.xbmc.subtitles/resources/lib/services/GomTV/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,8 @@ def __init__ (self):

def SearchSubtitlesFromTitle (self, searchString,key):
subtitles = []
subtitles = []

q_url = "http://gom.gomtv.com/jmdb/search.html?key=%s" %key
print q_url
log(__name__, "search subtitle at %s" %q_url)

# main page
Expand Down Expand Up @@ -102,31 +101,48 @@ def SearchSubtitlesFromTitle (self, searchString,key):
# regular search result page
soup = BeautifulSoup(html)
subtitles = []
for row in soup.find("table",{"class":"tbl_lst"}).findAll("tr")[1:]:
a_node = row.find("a")
if a_node is None:
continue
title = a_node.text
lang_node_string = row.find("span",{"class":"txt_clr3"}).string
url = self.root_url + a_node["href"]
if u"한글" in lang_node_string:
langlong = "Korean"
elif u"영문" in lang_node_string:
langlong = "English"
else: # [통합]
langlong = "Korean"
if "a href=\"jamak://gom.gomtv.com" in html:
title = soup.find("div",{"class":"row_r cpd2"}).text
print q_url
print title
langlong = "Korean"
langshort = languageTranslate(langlong, 0, 2)
subtitles.append( {
"link" : url,
"link" : q_url,
"filename" : title,
"ID" : key,
"format" : "smi",
"sync" : True,
"rating" : "0",
"language_name" : langlong,
"language_name" : "Korean",
"language_flag" : "flags/%s.gif" %langshort
} )

} )
else:
for row in soup.find("table",{"class":"tbl_lst"}).findAll("tr")[1:]:
a_node = row.find("a")
if a_node is None:
continue
title = a_node.text
lang_node_string = row.find("span",{"class":"txt_clr3"}).string
url = self.root_url + a_node["href"]
if u"한글" in lang_node_string:
langlong = "Korean"
elif u"영문" in lang_node_string:
langlong = "English"
else: # [통합]
langlong = "Korean"
langshort = languageTranslate(langlong, 0, 2)
subtitles.append( {
"link" : url,
"filename" : title,
"ID" : key,
"format" : "smi",
"sync" : True,
"rating" : "0",
"language_name" : langlong,
"language_flag" : "flags/%s.gif" %langshort
} )

q_url = "http://gom.gomtv.com/main/index.html?ch=subtitles&pt=l&menu=subtitles&lang=0&sValue=%s" %searchString
print q_url
log(__name__, "search subtitle at %s" %q_url)
Expand Down Expand Up @@ -157,10 +173,10 @@ def SearchSubtitlesFromTitle (self, searchString,key):
req.add_header("User-Agent", self.agent_str)
html = urllib2.urlopen(req).read()
# regular search result page
soup = BeautifulSoup(html)
soup = BeautifulSoup(html)
for row in soup.find("table",{"class":"tbl_lst"}).findAll("tr")[1:]:
if row is None:
continue
continue
a_node = row.find("a")
if a_node is None:
continue
Expand All @@ -183,7 +199,8 @@ def SearchSubtitlesFromTitle (self, searchString,key):
"rating" : "0",
"language_name" : langlong,
"language_flag" : "flags/%s.gif" %langshort
} )
} )

return subtitles

def parseRedirectionPage(self, html):
Expand All @@ -205,6 +222,6 @@ def GetSubtitleUrl (self, page_url):
capSeq = re.split("'",s1)[3]
sp2 = "/main/index.html?pt=down&ch=subtitles&intSeq="+intSeq+"&capSeq="+capSeq
else:
return None
print sp2
log(__name__,"Cannot parse download page: webpage change?")
return None
return self.root_url+sp2