def getCriticker(): apikey = settings.getSetting('criticker_apikey') if len(apikey) < 5: common.Notification('Error', 'Please set up Criticker key in settings') settings.openSettings() return url = 'http://api.criticker.com/handler.php?CritickerKey=%%API_KEY%%&Function=RecommendFilm' url = url.replace("%%API_KEY%%", apikey) print url req = urllib2.Request(url) req.add_header( 'User-Agent', "%s %s" % (sys.modules["__main__"].__plugin__, sys.modules["__main__"].__version__)) response = urllib2.urlopen(req) dom = parse(response) try: title = dom.getElementsByTagName("FilmName")[0].firstChild.data year = dom.getElementsByTagName("FilmYear")[0].firstChild.data avgtier = dom.getElementsByTagName("AvgTier")[0].firstChild.data except: common.Notification('Error', 'Please check your Criticker key in settings') settings.openSettings() return s = '{0} ({1}) r:{2}'.format(title, year, avgtier) common.createMovieListItem(s, title, year) url = sys.argv[0] + '?action=' common.createListItem('Another', True, url + 'criticker') common.endofDir() return
def setup(): if FIRST_TIME_STARTUP: dialog = xbmcgui.Dialog() dialog.ok("Furk Library BY alicanlakot", "..", "Welcome to first time", "setup") if not check_sources_xml(MOVIES_PATH) or not check_sources_xml( TV_SHOWS_PATH): if dialog.yesno( "Setup folder", "The directories used are not listed as video sources.", "Do you want to add them to sources.xml now?"): setup_sources() data = traktlib.testUser(settings.getSetting('trakt_login'), settings.getSetting('trakt_password')) if data['status'] == 'failure': common.Notification( data['status'], 'Please check your username for Trakt and Furk in config') settings.openSettings() data = traktlib.testUser(settings.getSetting('trakt_login'), settings.getSetting('trakt_password')) common.Notification('Tried again:', data['status']) if len(settings.getSetting('furk_apikey')) < 5: furklib.login(settings.getSetting('furk_login'), settings.getSetting('furk_password')) dialog.ok("Furk Library BY alicanlakot", "..", "You can start this again", "from menu") settings.setSetting('first_time_startup', 'false')
def getWatchlistShows(): tot = 0 shows = traktlib.getWatchlistShowsfromTrakt() # for myshow in shows: # # seasons = traktlib.getSeasons(myshow['tvdb_id']) # common.Notification('Getting:', myshow['title']) # for season in seasons: # if season['season']==0: # continue # #print 'Season:' + str(season['season']) # episodes = traktlib.getEpisodes(myshow['tvdb_id'],season['season']) # for myepisode in episodes: # if not False: #myepisode['watched']: # #print episode['title'] # tot = tot + common.createShowStrm(myshow['title'],myepisode['season'],myepisode['number'],myshow['tvdb_id']) # return tot for myshow in shows: if common.checkEnded(myshow['title']) == False: fullshow = traktlib.getFullShow(myshow['tvdb_id']) seasons = fullshow['seasons'] common.Notification('Getting:', myshow['title']) for season in seasons: if season['season']==0: continue episodes = season['episodes'] for myepisode in episodes: tot = tot + common.createShowStrm(myshow['title'],myepisode['season'],myepisode['number'],myshow['tvdb_id']) common.putShowStatus(fullshow['title'],fullshow['status']) return tot
def getVCDQ(url): d = feedparser.parse(url) common.Notification("Navigating to ", d['feed']['title']) mylist = list() for span in d.entries: rssname = span.title myPlot = span.description parser = MovieParser() parser.data = rssname parser.parse() myName = parser.name myYear = parser.year #year = s[len(s)-7 : len(s)] #year = year.replace('(','').replace(')','') #year = year.strip() #s = s.split('(',1)[0].strip() #s = s.replace(', The','') #print s s = myName + '(' + str(myYear) + ')' if s in mylist: continue else: common.createMovieListItem(s, myName, myYear, len(d.entries)) mylist.append(s) common.endofDir() return
def SearchDialog(type, title, year, season, number, go=False): if go: updateDialog = xbmcgui.DialogProgress() updateDialog.create("Furk Library", "Searching") updateDialog.update(20, "searching", title) oneclick = settings.getSetting("oneclick") if type == 'Show': search = searcherLib.ShowSearch(title, season, number, oneclick) else: search = searcherLib.MovieSearch(title, year, oneclick) if len( search.qualities ) < 2 and search.oneClickSatisfied == False and search.mediatype == 'Show': common.Notification('Furk Library 2', 'making a deep search') search.deepsearch() if search.oneclick: if search.oneClickSatisfied: common.Notification('Furk Library 2', 'found one click') return search.best_quality_result.dir[ 'name'], search.best_quality_result.mediaUrl() elif search.best_quality_result: common.Notification('Furk Library 2', 'one click not found playing nearest') quality_select = 0 else: pass #see what are our options if search.valids > 1: dialog = xbmcgui.Dialog() quality_select = dialog.select('Select quality', search.quality_options()) elif search.valids == 1: common.Notification('Found only:', search.results[0].text.split(' ', 1)[0]) quality_select = 0 else: dialog = xbmcgui.Dialog() dialog.ok("Error", "Nothing found", "Try searching in FurkLib Plugin") quality_select = -1 if quality_select == -1: return None, None else: print 'Quality' + str(quality_select) return search.results[quality_select].dir['name'], search.results[ quality_select].mediaUrl()
def rottenAction(params): if(params['action'] == 'rotten_Menu'): displayRottenMenu() elif(params['action'] == 'rotten_CurrentReleaseDvds'): # Search rottenCommon('api.rottentomatoes.com/api/public/v1.0/lists/dvds/top_rentals.json?apikey=cn6g7mzgatbfaxvza35nyjf8') elif(params['action'] == 'rotten_common'): rottenCommon(params['url']) else: common.Notification('Action Not found:' , params['action'])
def addToXbmcLib(fg=None): totalAdded = 0 if settings.getSetting("auto_addImdb") == 'true': url = settings.getSetting("imdb_watchlist") imdbmovies = imdb.watchlist_movies(url, 0) traktlib.addMoviestoWatchlist(imdbmovies) imdbshows = imdb.watchlist_shows(url, 0) traktlib.addShowstoWatchList(imdbshows) if settings.getSetting("add_trending") == 'true': if fg == 'True': common.Notification('Getting:', 'Trending') movies = traktlib.getTrendingMoviesFromTrakt() if movies: for movie in movies: if not movie['watched'] and movie['watchers'] > 1: totalAdded = totalAdded + common.createMovieStrm(movie['title'], movie['year'], movie['imdb_id']) common.createMovieNfo(movie['title'], movie['year'], movie['imdb_id']) if settings.getSetting("add_recommended") == True: if fg == 'True': common.Notification('Getting:', 'Recommended') movies = traktlib.getRecommendedMoviesFromTrakt() if movies: for movie in movies: totalAdded = totalAdded + common.createMovieStrm(movie['title'], movie['year'], movie['imdb_id']) common.createMovieNfo(movie['title'], movie['year'], movie['imdb_id']) if fg == 'True': common.Notification('Getting:', 'Watchlist Movies') if settings.getSetting("add_watchlistmovies") == 'true': if fg == 'True': common.Notification('Getting:', 'Watchlist Movies') movies = traktlib.getWatchlistMoviesFromTrakt() for movie in movies: totalAdded = totalAdded + common.createMovieStrm(movie['title'], movie['year'], movie['imdb_id']) common.createMovieNfo(movie['title'], movie['year'], movie['imdb_id']) if settings.getSetting("add_watchlistshows") == 'true': if fg == 'True': common.Notification('Getting:', 'Watchlist Shows') totalAdded = totalAdded + getWatchlistShows() if fg == 'True': common.Notification('Total:', str(totalAdded)) return totalAdded
def traktAction(params): if(params['action'] == 'trakt_Menu'): displayTraktMenu() elif(params['action'] == 'trakt_SearchMovies'): # Search keyboard = xbmc.Keyboard('', 'Search') keyboard.doModal() if keyboard.isConfirmed(): query = keyboard.getText() movies = traktlib.getMovieInfobySearch(unicode(query)) for movie in movies: common.createMovieListItemTrakt(movie,totalItems = len(movies)) common.endofDir() elif(params['action'] == 'trakt_SearchShows'): # Search keyboard = xbmc.Keyboard('', 'Search') keyboard.doModal() if keyboard.isConfirmed(): query = keyboard.getText() shows = traktlib.getShowInfobySearch(unicode(query)) for show in shows: common.createShowListItemTrakt(show,totalItems = len(shows)) common.endofDir() elif(params['action'] == 'trakt_SeenRate'): imdbid = params['imdbid'] traktSeenRate(imdbid) elif(params['action'] == 'trakt_DismissMovie'): imdbid = params['imdbid'] traktDismissMovie(imdbid) elif(params['action'] == 'trakt_MovieGenres'): displayGenres(type='Movie') elif(params['action'] == 'trakt_ShowGenres'): displayGenres(type='Show') elif(params['action'] == 'trakt_RecommendedShows'): try: genre = params['genre'] except: genre = None if genre: displayRecommendedShows(genre) else : url = sys.argv[0]+'?action=trakt_ShowGenres' common.createListItem('Filter by Genre', True, url) displayRecommendedShows(genre) elif(params['action'] == 'trakt_listfeeds'): myfeeds = furklib.myFeeds()['feeds'] myfeeds = sorted(myfeeds,key=lambda feed: feed['name']) url = sys.argv[0]+'?action=trakt_addfeeds' common.createListItem('Add Feeds from trakt', True, url) for feed in myfeeds: url = sys.argv[0]+'?action=trakt_MovieGenres' common.createListItem(feed['name'], True, url) common.endofDir() elif(params['action'] == 'trakt_addfeeds'): myfeeds = furklib.myFeeds()['feeds'] shows = traktlib.getWatchlistShowsfromTrakt() progress = traktlib.getProgress() series = [] for current in progress: series.append(current['show']) shows = shows + series for show in shows: check = [feed for feed in myfeeds if feed['name'] == show['title']] if len(check)==0: furklib.addFeed(show['title']) url = sys.argv[0]+'?action=trakt_MovieGenres' common.createListItem(show['title'], False, '') common.endofDir() elif(params['action'] == 'trakt_RecommendedMovies'): try: genre = params['genre'] except: genre = None if genre: displayRecommendedMovies(genre) else : url = sys.argv[0]+'?action=trakt_MovieGenres' common.createListItem('Filter by Genre', True, url) displayRecommendedMovies(genre) elif(params['action'] == 'trakt_AddShowtoWatchlist'): tvdbid = params['tvdbid'] addShowtoWatchlist(tvdbid) elif(params['action'] == 'trakt_AddMovietoWatchlist'): imdbid = params['imdbid'] addMovietoWatchlist(imdbid) elif(params['action'] == 'trakt_RemoveMoviefromWatchlist'): imdbid = params['imdbid'] response = traktlib.removeMoviefromWatchlist(imdbid) common.traktResponse(response) elif(params['action'] == 'trakt_DismissShow'): tvdbid = params['tvdbid'] traktDismissShow(tvdbid) elif(params['action'] == 'trakt_SetShowSeen'): tvdbid = params['tvdbid'] try: season = params['season'] episode = params['episode'] except: season = 100 episode = 100 response = traktSeenShow(tvdbid,season,episode) elif(params['action'] == 'trakt_TrendingMovies'): movies = traktlib.getTrendingMoviesFromTrakt() for movie in movies: common.createMovieListItemTrakt(movie,totalItems = len(movies)) common.endofDir() elif(params['action'] == 'trakt_TrendingShows'): shows = traktlib.getTrendingShowsFromTrakt() progressShows = calculateProgress() for show in shows: if show['title'] in progressShows: common.createShowListItemTrakt(show,len(shows),progressShows[show['title']][0],progressShows[show['title']][1]) else: common.createShowListItemTrakt(show,totalItems = len(shows)) common.endofDir() elif(params['action'] == 'trakt_Progress'): displayProgress() elif(params['action'] == 'trakt_getList'): user=params['user'] slug=params['slug'] displayList(user,slug) else: common.Notification('Action Not found:' , params['action'])
def traktDismissShow(tvdbid): response = traktlib.dismissShow(tvdbid) common.Notification(response['status'],response['message'])
def musicAction(params): if (params['action'] == 'about'): # Play a file collector.Notification(__plugin__, __version__) elif (params['action'] == 'music_search'): # Search keyboard = xbmc.Keyboard('', 'Search') keyboard.doModal() if keyboard.isConfirmed(): query = keyboard.getText() searcher.SearchFromMenu(query) elif (params['action'] == 'music_myFiles'): searcher.getMyFiles() elif (params['action'] == 'listFiles'): id = params['id'] searcher.ListFiles(id) elif (params['action'] == 'movielens'): # Search movielens.displayMovieLensmenu() elif (params['action'] == 'movielensUrl'): # Search url = params['url'] xbmcplugin.setContent(int(sys.argv[1]), 'movies') movielens.getMovieLens(url) common.endofDir() elif (params['action'] == 'criticker'): # Search xbmcplugin.setContent(int(sys.argv[1]), 'movies') criticker.getCriticker() elif (params['action'] == 'vcdq'): url1 = "http://www.vcdq.com/browse/rss/1/0/0/10_9_11_3_2_6_4/0/0/0" xbmcplugin.setContent(int(sys.argv[1]), 'movies') vcdq.getVCDQ(url1) elif (params['action'] == 'torrentfreak'): xbmcplugin.setContent(int(sys.argv[1]), 'movies') url1 = "http://torrentfreak.com/category/dvdrip/feed/" torrentfreak.getpopular(url1) elif (params['action'] == 'scrapeMovie'): title = params['title'] year = params['year'] common.createMovieStrm(title, year, MOVIES_PATH) common.Notification('Added to library:', title) xbmc.executebuiltin('UpdateLibrary(video)') elif (params['action'] == 'SearchMe'): # Search type = params['type'] year = 0 season = 0 episode = 0 movie = None if type == 'Show': type = params['type'] season = params['season'] episode = params['episode'] title = params['title'] try: tvdbid = params['tvdbid'] except: tvdbid = None if tvdbid: episodedata = traktlib.getEpisodeInfo(tvdbid, season, episode) else: episodedata = None elif type == 'Movie': title = params['title'] year = params['year'] imdbid = params['imdbid'] movie = common.getMovieInfobyImdbid(imdbid) else: type = 'Movie' title = params['query'] try: go = params['go'] go = True except: go = False myname, myurl = searcher.SearchDialog(type, title, year, season, episode) if myurl: #common.Notification("Found"," and playing!") time.sleep(1) listitem = xbmcgui.ListItem(myname, path=myurl) listitem.setLabel(myname) listitem.setProperty("IsPlayable", "true") if movie: common.addMovieInfotoPlayListitem(listitem, movie) #common.Notification("Found"," Movie!") elif episodedata: common.addEpisodeInfotoListitem(listitem, episodedata) xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem) print myname print myurl if go: xbmc.Player().play(myurl, listitem) else: xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xbmcgui.ListItem()) elif (params['action'].startswith('imdb_')): imdb.imdbAction(params) elif (params['action'].startswith('trakt_')): trakt.traktAction(params) elif (params['action'].startswith('rotten_')): rotten.rottenAction(params) elif (params['action'] == 'traktlib'): try: fg = params['fg'] except: fg = 'True' totalAdded = trakt.addToXbmcLib(fg) totalAdded += imdb.addImdbToLib(fg) if totalAdded > 0: common.Notification('Furk-Trakt', '{0} were added'.format(totalAdded)) xbmc.executebuiltin('UpdateLibrary(video)') if fg == 'False': settings.startTimer() elif (params['action'] == 'download'): url = params['url'] filename = params['filename'] common.download(url, filename) elif (params['action'] == 'setup'): settings.setSetting('first_time_startup', 'true') FIRST_TIME_STARTUP = settings.first_time_startup() setup() else: # torrents a root Directories xbmc.log('argv=%s' % sys.argv) if (MYCONTEXT == 'video'): common.createCachePath() setup() AddonMenu() else: music.MusicMenu() print 'Closing FurkLib'
elif (params['action'] == 'vcdq'): url1 = "http://www.vcdq.com/browse/rss/1/0/0/10_9_11_3_2_6_4/0/0/0" xbmcplugin.setContent(int(sys.argv[1]), 'movies') vcdq.getVCDQ(url1) elif (params['action'] == 'torrentfreak'): xbmcplugin.setContent(int(sys.argv[1]), 'movies') url1 = "http://torrentfreak.com/category/dvdrip/feed/" torrentfreak.getpopular(url1) elif (params['action'] == 'scrapeMovie'): title = params['title'] year = params['year'] common.createMovieStrm(title, year, MOVIES_PATH) common.Notification('Added to library:', title) xbmc.executebuiltin('Library(video)') elif (params['action'] == 'Trailers'): #xbmc.executebuiltin("XBMC.RunScript(special://home/addons/script.furktrailers/default.py)") xbmc.executebuiltin( "XBMC.RunScript(special://home/addons/plugin.video.furklibraryx/trailers.py)" ) elif (params['action'] == 'SearchMe'): # Search type = params['type'] year = 0 season = 0 episode = 0 movie = None