Exemplo n.º 1
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.º 2
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.º 3
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']