Exemple #1
0
def getImdbAwards(type,year):
	if type == 'Oscars':
		url = 'http://www.imdb.com/event/ev0000003/{0}'.format(year)
	elif type == 'Cannes':
		url = 'http://www.imdb.com/event/ev0000147/{0}'.format(year)
	response = urllib2.urlopen(url)
	html = response.read()
	soup = BeautifulSoup(html)
	#print soup.prettify()
	winners = soup.findAll('h2')
	movies = dict()
	for winner in winners:
	    category = winner.text
	    try:
		    h3 = winner.findNextSibling('blockquote').h3
	    except:
		continue
	    winnerdiv = h3.findNextSibling('div')
	    link = winnerdiv.find(href=re.compile("/title/tt(\d{7})/"))
	    imdb_number = re.match(r'/title/tt(\d{7})/',link.get('href')).group(1)
	    if not imdb_number in movies.keys():
		    movie = common.getMovieInfobyImdbid(imdb_number)
		    if movie:
			    movies[imdb_number] = movie
		    else:
			    movies[imdb_number] = None
	    else:
                    movie= movies[imdb_number]
	    common.createListItem(category, False, '',len(winners)*2)
	    if movie:
		common.createMovieListItemTrakt(movie,len(winners)*2)
	    else:
		common.createListItem(imdb_number, False, '',len(winners)*2)
	common.endofDir()
        return 
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
        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':
        imdbid = params['imdbid']
        movie = common.getMovieInfobyImdbid(imdbid)
        if movie:
			title = movie['title']
			year = movie['year']
        else:
			title = params['title']
			year = params['year']
    else:
		type = 'Movie'
		title = params['query']

    go = False
    try:
        go = params['go']
        if go:
            go=True
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
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'
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'
        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':
        imdbid = params['imdbid']
        movie = common.getMovieInfobyImdbid(imdbid)
        if movie:
            title = movie['title']
            year = movie['year']
        else:
            title = params['title']
            year = params['year']
    else:
        type = 'Movie'
        title = params['query']

    go = False
    try:
        go = params['go']
        if go:
            go = True