def checkSubtitles (self): ''' ''' for entry in self.subpending: self.log.write( "Looking for sub to " + entry[0] + " S" + str(entry[1]).zfill(2) + "E" + str(entry[2]).zfill(2),1) subSearch = subService.search_subtitles("", "", entry[0],"",str(entry[1]),str(entry[2]),"","","Spanish","","","") if len(subSearch[0]) > 0: flag = 0 for i in range(len(subSearch[0])): tipo = re.compile( "\((.*)\)" ).search( str(subSearch[0][i]["filename"]) ).group( 1 ) #print "Tipo: " + tipo if tipo == "ESPAÑA": subService.download_subtitles(subSearch[0],i,None,self.downloadFolder,None,None) flag = 1 if flag == 1: self.log.write( "Found, removing...",2) notify("Subtitles for " + entry[0] + " S" + str(entry[1]).zfill(2) + "E" + str(entry[2]).zfill(2) + " downloaded") self.subpending.remove(entry)
def checkShows(self): for show in self.configFile.sections(): self.log.write(show, 1) self.log.write("Downloading RSS file...", 2) showrssUrl = self.configFile.get(show, "rss") feed = feedparser.parse(showrssUrl) last_chapter = int(self.configFile.get(show, "last_chapter")) last_season = int(self.configFile.get(show, "last_season")) # Try to download the RSS correctly counter = 1 while feed["bozo"] == 1: # self.log.write("Failed, retrying...") feed = None feed = feedparser.parse(showrssUrl) counter += 1 if counter == 11: self.log.write("Cannot download RSS", 2) break # Get chapter entries from the RSS items = feed["items"] flag = 0 new_season = last_season new_chapter = last_chapter for item in items: title = str(item["title"].encode("utf8")) if not "720p" in title: continue """titlStr = re.sub("(.*) \[.*\]","\g<1>", title) chp = titlStr.split()[-1:][0] chpp = chp.split('x')""" # print "Last: " + str(last_season) + "x" + str(last_chapter) season = int(re.sub(".*([0-9])x([0-9][0-9]) .*", "\g<1>", title)) chapter = int(re.sub(".*([0-9])x([0-9][0-9]) .*", "\g<2>", title)) if (season > last_season or (season == last_season and chapter > last_chapter)) and flag == 0: self.log.write("New episode: Season: " + str(season) + ". Chapter: " + str(chapter), 2) # print "Season " + str(chpp[0]) + " chapter " + chpp[1] os.system( 'transmission-remote --add "' + item["link"] + '" --auth transmission:esteesmiservidortorrent' ) # notify chpstr = show + " S" + str(season).zfill(2) + "E" + str(chapter).zfill(2) notify("Downloading " + chpstr) # subs self.subtitler.addSub([show, season, chapter]) if season > new_season or ((season == new_season) and (chapter > new_chapter)): new_season = season new_chapter = chapter else: flag = 1 self.configFile.set(show, "last_chapter", str(new_chapter)) self.configFile.set(show, "last_season", str(new_season)) with open(self.showFile, "wb") as configWrite: self.configFile.write(configWrite)