Пример #1
0
 def __init__(self,fullpath,file_name,name,year,imdbid):
     self.file_name = file_name#check if needed all below
     self.path = os.path.dirname(fullpath)
     self.name = name
     self.year = year
     self.id = imdbid
     if parseNFO and self.id == None:
         files = []
         for root, dirs, walk_files in os.walk(self.path):
             files.extend([sp(os.path.join(root, file)) for file in walk_files]) #not sure if sp is needed
         #self.x = getNfo(files)
         for file in getNfo(files):
             self.id = getIDFromNFO('MOVIE', file)
             if self.id != '':
                 break
     if pchtrakt.online and (self.id == None or self.id == ''):
         retries = 0
         while self.id == None:
             self.id = self.imdbapi1()
             if (self.id != None or self.id != ''):
                 break
             self.id = self.imdbapi2()
             if (self.id != None or self.id != ''):
                 break
             self.id = self.imdbapi3()
             if (self.id != None or self.id != ''):
                 break
             if retries >= 1:
                 raise MovieResultNotFound(file_name)
                 break
             else:
                 msg = ('[IMDB api] First lookup failed, trying 1 more time')
                 pchtrakt.logger.warning(msg)
                 retries += 1
                 sleep(60)
                 continue
Пример #2
0
 def __init__(self, fullpath, file_name, name, year, imdbid):
     self.file_name = file_name  # check if needed all below
     self.path = os.path.dirname(fullpath)
     self.name = name
     self.year = year
     self.id = imdbid
     if parseNFO and self.id == None:
         files = []
         for root, dirs, walk_files in os.walk(self.path):
             files.extend([sp(os.path.join(root, file)) for file in walk_files])  # not sure if sp is needed
         # self.x = getNfo(files)
         for file in getNfo(files):
             self.id = getIDFromNFO("MOVIE", file)
             if self.id != "":
                 break
     if pchtrakt.online and (self.id == None or self.id == ""):
         retries = 0
         while self.id == None:
             self.id = self.imdbapi1()
             if self.id != None or self.id != "":
                 break
             self.id = self.imdbapi2()
             if self.id != None or self.id != "":
                 break
             self.id = self.imdbapi3()
             if self.id != None or self.id != "":
                 break
             if retries >= 1:
                 raise MovieResultNotFound(file_name)
                 break
             else:
                 msg = "[IMDB api] First lookup failed, trying 1 more time"
                 pchtrakt.logger.warning(msg)
                 retries += 1
                 sleep(60)
                 continue
Пример #3
0
 def __init__(self,file_name,name,dirty,season_number,episode_numbers,air_by_date):
     self.file_name = file_name
     self.path = os.path.dirname(file_name)
     self.name = name
     self.air_by_date = air_by_date
     self.dirty = dirty
     self.id = ''
     #np = parser.NameParser()
     #parse_result = np.parse(self.file_name)
     if self.air_by_date:
         if self.name in pchtrakt.dictSerie:
             self.id = pchtrakt.dictSerie[self.name]['TvDbId']
         else:
             self.id = tvdb[self.name]['id']
         season_number = -1
         episode_numbers = [self.air_by_date]
         url = ('http://thetvdb.com/api/GetEpisodeByAirDate.php?apikey=0629B785CE550C8D&seriesid={0}&airdate={1}'.format(quote_plus(self.id), self.air_by_date))
         Debug('[The TvDB] GET EPISODE USING: ' + url)
         oResponse = ElementTree.parse(urlopen(url,None,5))
         #feed = RSSWrapper(tree.getroot())
         for movie in oResponse.findall('./'):
             #Debug("movie", repr(movie.title), movie.link)
             season_number = movie.find('SeasonNumber').text
             episode_numbers = movie.find('EpisodeNumber').text
     self.season_number = season_number
     self.episode_numbers = episode_numbers
     if self.name in pchtrakt.dictSerie:
         self.id = pchtrakt.dictSerie[self.name]['TvDbId']
         self.year = pchtrakt.dictSerie[self.name]['Year']
     else:
         if parseNFO:
             files = []
             if (self.file_name.split(".")[-1] == "DVD" or self.file_name.split(".")[-1].lower() == "iso"):
                 if isfile(self.path.rsplit('/', 2)[0] + '/tvshow.nfo'):
                     pchtrakt.logger.info(' [Pchtrakt] found ../../tvshow.nfo')
                     files.extend([(self.path.rsplit('/', 1)[0] + '/tvshow.nfo')])
             elif isfile(self.path.rsplit('/', 1)[0] + '/tvshow.nfo'):
                 pchtrakt.logger.info(' [Pchtrakt] found ../tvshow.nfo')
                 files.extend([(self.path.rsplit('/', 1)[0] + '/tvshow.nfo')])
             else:
                 for root, dirs, walk_files in os.walk(self.path):
                     files.extend([(os.path.join(root, file)) for file in walk_files])
             for file in getNfo(files):
                 pchtrakt.logger.info(' [Pchtrakt] parsing %s' % file)
                 self.id = getIDFromNFO('TV', file)
                 if self.id != '':
                     try:
                         if (re.match("tt\d{5,10}", self.id)):
                             pchtrakt.logger.info(' [Pchtrakt] Using IMDB ID to find match')
                             self.id = tvdb[self.id]['id']
                             #self.id = int(self.id)
                         self.name = tvdb[int(self.id)]['seriesname']
                         pchtrakt.online = 1
                         if tvdb[self.name]['firstaired'] != None:
                             self.year = tvdb[self.name]['firstaired'].split('-')[0]
                         else:
                             self.year = None
                         pchtrakt.dictSerie[self.name]={'Year':self.year, 'TvDbId':self.id}
                         with open('cache.json','w') as f:
                             json.dump(pchtrakt.dictSerie, f, separators=(',',':'), indent=4)
                     except tvdb_exceptions.tvdb_error, e:
                         pchtrakt.online = 0
                     break
         if self.id == '':
             try:
                 self.id = tvdb[self.name]['id']
                 pchtrakt.online = 1
                 if tvdb[self.name]['firstaired'] != None:
                     self.year = tvdb[self.name]['firstaired'].split('-')[0]
                 else:
                     self.year = None
                 pchtrakt.dictSerie[self.name]={'Year':self.year, 'TvDbId':self.id}
                 with open('cache.json','w') as f:
                     json.dump(pchtrakt.dictSerie, f, separators=(',',':'), indent=4)
             except tvdb_exceptions.tvdb_error, e:
                 pchtrakt.online = 0
Пример #4
0
 def __init__(self, file_name, name, dirty, season_number, episode_numbers, air_by_date):
     self.file_name = file_name
     self.path = os.path.dirname(file_name)
     self.name = name
     self.air_by_date = air_by_date
     self.dirty = dirty
     self.id = ""
     # np = parser.NameParser()
     # parse_result = np.parse(self.file_name)
     if self.air_by_date:
         if self.name in pchtrakt.dictSerie:
             self.id = pchtrakt.dictSerie[self.name]["TvDbId"]
         else:
             self.id = tvdb[self.name]["id"]
         season_number = -1
         episode_numbers = [self.air_by_date]
         url = "http://thetvdb.com/api/GetEpisodeByAirDate.php?apikey=0629B785CE550C8D&seriesid={0}&airdate={1}".format(
             quote_plus(self.id), self.air_by_date
         )
         Debug("[The TvDB] GET EPISODE USING: " + url)
         oResponse = ElementTree.parse(urlopen(url, None, 5))
         # feed = RSSWrapper(tree.getroot())
         for movie in oResponse.findall("./"):
             # Debug("movie", repr(movie.title), movie.link)
             season_number = movie.find("SeasonNumber").text
             episode_numbers = movie.find("EpisodeNumber").text
     self.season_number = season_number
     self.episode_numbers = episode_numbers
     if self.name in pchtrakt.dictSerie:
         self.id = pchtrakt.dictSerie[self.name]["TvDbId"]
         self.year = pchtrakt.dictSerie[self.name]["Year"]
     else:
         if parseNFO:
             files = []
             if self.file_name.split(".")[-1] == "DVD" or self.file_name.split(".")[-1].lower() == "iso":
                 if isfile(self.path.rsplit("/", 2)[0] + "/tvshow.nfo"):
                     pchtrakt.logger.info(" [Pchtrakt] found ../../tvshow.nfo")
                     files.extend([(self.path.rsplit("/", 1)[0] + "/tvshow.nfo")])
             elif isfile(self.path.rsplit("/", 1)[0] + "/tvshow.nfo"):
                 pchtrakt.logger.info(" [Pchtrakt] found ../tvshow.nfo")
                 files.extend([(self.path.rsplit("/", 1)[0] + "/tvshow.nfo")])
             else:
                 for root, dirs, walk_files in os.walk(self.path):
                     files.extend([(os.path.join(root, file)) for file in walk_files])
             for file in getNfo(files):
                 pchtrakt.logger.info(" [Pchtrakt] parsing %s" % file)
                 self.id = getIDFromNFO("TV", file)
                 if self.id != "":
                     try:
                         if re.match("tt\d{5,10}", self.id):
                             pchtrakt.logger.info(" [Pchtrakt] Using IMDB ID to find match")
                             self.id = tvdb[self.id]["id"]
                             # self.id = int(self.id)
                         self.name = tvdb[int(self.id)]["seriesname"]
                         pchtrakt.online = 1
                         if tvdb[self.name]["firstaired"] != None:
                             self.year = tvdb[self.name]["firstaired"].split("-")[0]
                         else:
                             self.year = None
                         pchtrakt.dictSerie[self.name] = {"Year": self.year, "TvDbId": self.id}
                         with open("cache.json", "w") as f:
                             json.dump(pchtrakt.dictSerie, f, separators=(",", ":"), indent=4)
                     except tvdb_exceptions.tvdb_error, e:
                         pchtrakt.online = 0
                     break
         if self.id == "":
             try:
                 self.id = tvdb[self.name]["id"]
                 pchtrakt.online = 1
                 if tvdb[self.name]["firstaired"] != None:
                     self.year = tvdb[self.name]["firstaired"].split("-")[0]
                 else:
                     self.year = None
                 pchtrakt.dictSerie[self.name] = {"Year": self.year, "TvDbId": self.id}
                 with open("cache.json", "w") as f:
                     json.dump(pchtrakt.dictSerie, f, separators=(",", ":"), indent=4)
             except tvdb_exceptions.tvdb_error, e:
                 pchtrakt.online = 0