Example #1
0
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
Example #2
0
def addToXbmcLib(fg = None):
	totalAdded=0
	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 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')	
	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 fg == 'True':
		common.Notification('Getting:','Calendar Shows')	
	d = datetime.date.today() + datetime.timedelta(days=-8)
	currentdate = d.strftime('%Y%m%d')
	series = traktlib.getShowsCalendarFromTrakt(currentdate)
	for show in series:
	    episodes = show['episodes']
    
	    for episode in episodes:
		myepisode = episode['episode']
	        myshow = episode['show']
		totalAdded = totalAdded + common.createShowStrm(myshow['title'],myepisode['season'],myepisode['number'],myshow['tvdb_id'])

	if fg == 'True':		
		common.Notification('Getting:','Watchlist Shows')	
	totalAdded = totalAdded + getWatchlistShows()
	if fg == 'True':
		common.Notification('Total:', str(totalAdded))
	return totalAdded
def getReco(channel):
	filename = PLAYLIST_PATH +  str(channel) + '.m3u'
	if not os.path.isfile(filename):
		refresh=True
	else:
		f = os.path.getmtime(filename)
		if time.time() - f > 1800:
			refresh=True
		else:
			refresh=False
	if refresh==False:
		return refresh
	count= 0
	updateDialog = xbmcgui.DialogProgress()
	updateDialog.create("FurkTrailers", "Receiving Movies from trakt")
	updateDialog.update(25, "Recommended", "Total: " + str(count))
	reco = traktlib.getRecommendedMoviesFromTrakt() 
	count = count + len(reco)
	updateDialog.update(50, "Watchlist", "Total: " + str(count))
	WL = traktlib.getWatchlistMoviesFromTrakt() 
	count = count + len(WL)
	updateDialog.update(75, "Trending", "Total: " + str(count))
	trending= traktlib.getTrendingMoviesFromTrakt()
	count = count + len(trending)
	
	updateDialog.update(99, "Imdb", "")
	imdbTop = []
	entries = imdb.getImdbRentalsList()
	for entry in entries:
		link_number,title,year = entry
		movie = common.getMovieInfobyImdbid(link_number)
		imdbTop.append(movie)
	updateDialog.update(99, "Imdb", "Len: " + str(len(entries)))
	updateDialog.close()

	if count==0:
		return
	
	movies = []
	if trending:
		movies= movies + trending
	if WL:
		movies= movies + WL
	if reco:
		movies = movies + reco
	if len(imdbTop)>0:
		movies = movies + imdbTop
	if len(movies)>0:
		fle = FileAccess.open(filename, 'w')
		flewrite = "#EXTM3U\n"
		for movie in movies:
			try:
				watched = movie['watched']
			except:
				watched = False
			try:
				inwatchlist= movie['in_watchlist']
			except:
				inwatchlist = False

			if movie['trailer']=='':
				continue
			if watched == True and inwatchlist == False:
				continue
			if movie in reco:
				type = 'Recommended'
			elif movie in imdbTop:
				type= 'Imdb Top Rentals'
			elif movie in WL:
				type= 'In Watchlist'
			elif movie in trending:
				if int(movie['watchers'])<2:
					continue
				else:
					type = 'Trending ' + str(movie['watchers']) + ' watchers'
			mygenre = ''
			try:
				for genre in movie['genres']:
					mygenre = mygenre + genre + ' / '
				if len(mygenre)>0:
					mygenre = mygenre[:-2] 
			except:
				pass


			# #EXTINF:5760,2 Days In Paris////Adam Goldberg delivers "an uproarious study in transatlantic culture panic" as Jack, an anxious, hypochondriac-prone New Yorker vacationing throughout Europe with his breezy, free-spirited Parisian girlfriend, Marion. But when they make a two-day stop in Marion's hometown, the couple's romantic trip takes a turn as Jack is exposed to Marion's sexually perverse and emotionally unstable family.
			tmpstr = str(movie['runtime']*60) + ','
			tmpstr = str(50) + ','
			try:
				imdbid= movie['imdb_id'].encode('utf-8').strip()
			except:
				imdbid= ''
			try:
				rating = str(movie['ratings']['percentage']/10.0) + ' ' + type + ' ' + mygenre.encode('utf-8').strip()
			except:
				rating = type
			poster= urllib.quote(movie['images']['poster'][7:])
			tmpstr += movie['title'].encode('utf-8').strip() + " (" + str(movie['year']) +  ")//" + rating + "//" + poster + "//" + imdbid + "//" + movie['overview'].encode('utf-8').strip()  
			tmpstr = tmpstr[:600]
			tmpstr = tmpstr.replace("\\n", " ").replace("\\r", " ").replace("\\\"", "\"")
			tmpstr = tmpstr + '\n' + getTrailer(movie['trailer']).encode('utf-8').strip()

			flewrite += "#EXTINF:" + tmpstr + "\n"
			#print movie
		
		fle.write(flewrite)
		fle.close()
		return refresh
Example #4
0
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 getReco(channel):
    filename = PLAYLIST_PATH + str(channel) + '.m3u'
    if not os.path.isfile(filename):
        refresh = True
    else:
        f = os.path.getmtime(filename)
        if time.time() - f > 1800:
            refresh = True
        else:
            refresh = False
    if refresh == False:
        return refresh
    count = 0
    updateDialog = xbmcgui.DialogProgress()
    updateDialog.create("FurkTrailers", "Receiving Movies from trakt")
    updateDialog.update(25, "Recommended", "Total: " + str(count))
    reco = traktlib.getRecommendedMoviesFromTrakt()
    count = count + len(reco)
    updateDialog.update(50, "Watchlist", "Total: " + str(count))
    WL = traktlib.getWatchlistMoviesFromTrakt()
    count = count + len(WL)
    updateDialog.update(75, "Trending", "Total: " + str(count))
    trending = traktlib.getTrendingMoviesFromTrakt()
    count = count + len(trending)

    updateDialog.update(99, "Imdb", "")
    imdbTop = []
    entries = imdb.getImdbRentalsList()
    for entry in entries:
        link_number, title, year = entry
        movie = common.getMovieInfobyImdbid(link_number)
        imdbTop.append(movie)
    updateDialog.update(99, "Imdb", "Len: " + str(len(entries)))
    updateDialog.close()

    if count == 0:
        return

    movies = []
    if trending:
        movies = movies + trending
    if WL:
        movies = movies + WL
    if reco:
        movies = movies + reco
    if len(imdbTop) > 0:
        movies = movies + imdbTop
    if len(movies) > 0:
        fle = FileAccess.open(filename, 'w')
        flewrite = "#EXTM3U\n"
        for movie in movies:
            try:
                watched = movie['watched']
            except:
                watched = False
            try:
                inwatchlist = movie['in_watchlist']
            except:
                inwatchlist = False

            if movie['trailer'] == '':
                continue
            if watched == True and inwatchlist == False:
                continue
            if movie in reco:
                type = 'Recommended'
            elif movie in imdbTop:
                type = 'Imdb Top Rentals'
            elif movie in WL:
                type = 'In Watchlist'
            elif movie in trending:
                if int(movie['watchers']) < 2:
                    continue
                else:
                    type = 'Trending ' + str(movie['watchers']) + ' watchers'
            mygenre = ''
            try:
                for genre in movie['genres']:
                    mygenre = mygenre + genre + ' / '
                if len(mygenre) > 0:
                    mygenre = mygenre[:-2]
            except:
                pass

            # #EXTINF:5760,2 Days In Paris////Adam Goldberg delivers "an uproarious study in transatlantic culture panic" as Jack, an anxious, hypochondriac-prone New Yorker vacationing throughout Europe with his breezy, free-spirited Parisian girlfriend, Marion. But when they make a two-day stop in Marion's hometown, the couple's romantic trip takes a turn as Jack is exposed to Marion's sexually perverse and emotionally unstable family.
            tmpstr = str(movie['runtime'] * 60) + ','
            tmpstr = str(50) + ','
            try:
                imdbid = movie['imdb_id'].encode('utf-8').strip()
            except:
                imdbid = ''
            try:
                rating = str(
                    movie['ratings']['percentage'] /
                    10.0) + ' ' + type + ' ' + mygenre.encode('utf-8').strip()
            except:
                rating = type
            poster = urllib.quote(movie['images']['poster'][7:])
            tmpstr += movie['title'].encode('utf-8').strip() + " (" + str(
                movie['year']
            ) + ")//" + rating + "//" + poster + "//" + imdbid + "//" + movie[
                'overview'].encode('utf-8').strip()
            tmpstr = tmpstr[:600]
            tmpstr = tmpstr.replace("\\n",
                                    " ").replace("\\r",
                                                 " ").replace("\\\"", "\"")
            tmpstr = tmpstr + '\n' + getTrailer(
                movie['trailer']).encode('utf-8').strip()

            flewrite += "#EXTINF:" + tmpstr + "\n"
            #print movie

        fle.write(flewrite)
        fle.close()
        return refresh