Exemplo n.º 1
0
 def _getImdbInfoFromUrl(self, imdbUrl, logIt=True):
     """ Search IMDB For the movieID's info. """
     try:
         if (not imdbUrl): return None
         if (logIt): log.fine("  Looking up movie: %s" % imdbUrl)
         movieID = re.findall(IMDB_REGEX, imdbUrl)[0]
         return imdbpy.get_movie(movieID)
     except imdb.IMDbDataAccessError:
         log.warn("  IMDB Data Access Error: %s" % imdbUrl)
         return None
Exemplo n.º 2
0
 def _searchYouTube(self, searchTitle, searchYear):
     """ Search YouTune for a Trailer URL. """
     log.info("  Searching YouTube for: '%s' (yr: %s)" % (searchTitle, searchYear))
     searchResults = youtube.search(searchTitle)
     # Select the correct YouTube Video (always ask user)
     choiceStr = lambda r: "%s - %s" % (r['title'], r['url'])
     searchSelection = util.promptUser(searchResults, choiceStr)
     if (not searchSelection):
         log.fine("  YouTube has no entry for: '%s' (yr: %s)" % (searchTitle, searchYear))
         return None
     return searchSelection['url']
Exemplo n.º 3
0
 def _searchTrailerAddict(self, searchTitle, searchYear):
     """ Search TrailerAddict for a Trailer URL """
     # Search TrailerAddict for the Movie
     log.info("  Searching TrailerAddict for: '%s' (yr: %s)" % (searchTitle, searchYear))
     searchResults = traileraddict.search(searchTitle)
     if (not searchResults):
         log.fine("  TrailerAddict has no search results for: '%s' (yr: %s)" % (searchTitle, searchYear))
         return None
     # Select the correct TrailerAddict Movie
     firstTitle = searchResults[0]['title']
     firstYear = searchResults[0]['year']
     if (firstTitle.lower() == searchTitle.lower()) and (int(firstYear) == searchYear):
         log.fine("  First result is exact match: %s (%s)" % (searchTitle, searchYear))
         searchSelection = searchResults[0]
     else:
         log.fine("  No exact TrailerAddict match found, prompting user")
         choiceStr = lambda r: "%s (%s) - %s" % (r['title'], r['year'], r['url'])
         searchSelection = util.promptUser(searchResults, choiceStr)
     if (not searchSelection):
         log.fine("  TrailerAddict has no entry for: '%s' (yr: %s)" % (searchTitle, searchYear))
         return None
     # Search for the correct Video (Traileraddict has many per movie)
     trailerUrls = traileraddict.getTrailerUrls(searchSelection['url'])
     trailerUrl = traileraddict.getMainTrailer(trailerUrls)
     if (not trailerUrl):
         log.info("  Main trailer not found, prompting user")
         choiceStr = lambda t: t
         trailerUrl = util.promptUser(trailerUrls, choiceStr)
     return trailerUrl
Exemplo n.º 4
0
 def lookupTrailerUrl(self, useAka=False):
     """ Lookup the trailer URL. """
     # No need to search if we already have a trailer
     if (self.trailerUrl):
         log.info("  Trailer URL already exists: %s" % self.trailerUrl)
         return None
     # Search for the Trailer URL
     searchTitle = self.title or self.curTitle
     if (useAka): searchTitle = self.aka or searchTitle
     searchYear = self.year or self.curYear or "NA"
     trailerUrl = self._searchTrailerAddict(searchTitle, searchYear)
     trailerUrl = trailerUrl or self._searchYouTube(searchTitle, searchYear)
     if (not trailerUrl):
         log.fine("  Found no trailer for: '%s' (yr: %s)" % (searchTitle, searchYear))
         return None
     # We found a new Trailer URL! :)
     self._newInfoFound = True
     self.trailerUrl = trailerUrl
Exemplo n.º 5
0
 def _getImdbUrlFromSearch(self, foreign=False):
     """ Search IMDB for the specified title. """
     # Search IMDB for potential matches
     title = self.curTitle
     year = self.curYear or "NA"
     log.info("  Searching IMDB for: '%s' (yr: %s)" % (title, year))
     results = imdbpy.search_movie(title, IMDB_MAX_RESULTS)
     # Check first 5 Results Title and year matches exactly
     selection = None
     for result in results[0:5]:
         if (self._weakMatch(result['title'], title)) and (int(result['year']) == year):
             log.fine("  Result match: %s (%s)" % (result['title'], result['year']))
             selection = result
             break
     # Ask User to Select Correct Result
     if (not selection):
         log.fine("  No exact IMDB match found, prompting user")
         if (not foreign): choiceStr = lambda r: "%s (%s) - %s" % (r['title'], r['year'], self.getUrl(r.movieID))
         else: choiceStr = lambda r: "%s (%s-%s): %s" % (r['title'], self._getCountry(r), r['year'], self._getAka(r))
         selection = util.promptUser(results, choiceStr)
     # If still no selection, return none
     if (not selection):
         log.fine("  IMDB has no entry for: %s (%s)" % (title, year))
         return None
     return self.getUrl(selection.movieID)
Exemplo n.º 6
0
 def saveNfo(self, foreign=False):
     """ Create the NFO file and store on disk.  Overwrite it if already exists.
         Format: http://xbmc.org/wiki/?title=Import_-_Export_Library#Video_nfo_Files
     """
     # Check we have new Information from the net
     if (self.curNfoName) and (not self._newInfoFound):
         log.fine("  No new info collected, skipping NFO create.")
         return None
     # All Set, Create the NFO!
     nfoPath = "%s/%s.nfo" % (self.dirPath, self.newFilePrefix)
     log.info("  Creating NFO file at: %s" % nfoPath)
     handle = open(nfoPath, 'w')
     handle.write("<xml>\n")
     if (self.imdbUrl): handle.write("  %s\n" % util.escape(self.imdbUrl))
     handle.write("  <movie>\n")
     if (self.title):      handle.write("    <title>%s</title>\n" % util.escape(self.title))
     if (self.year):       handle.write("    <year>%s</year>\n" % util.escape(self.year))
     if (self.country):    handle.write("    <country>%s</country>\n" % util.escape(self.country))
     if (self.aka):        handle.write("    <aka>%s</aka>\n" % util.escape(self.aka))
     if (self.imdbUpdate): handle.write("    <imdbupdate>%s</imdbupdate>\n" % self.imdbUpdate)
     if (self.trailerUrl): handle.write("    <trailerurl>%s</trailerurl>\n" % util.escape(self.trailerUrl))
     handle.write("  </movie>\n")
     handle.write("</xml>\n")
     handle.close()