This repository has been archived by the owner on May 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
trending.py
99 lines (77 loc) · 2.75 KB
/
trending.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# -*- coding: utf-8 -*-
#
import os
import xbmc,xbmcaddon,xbmcgui
import time, socket
try: import simplejson as json
except ImportError: import json
from utilities import *
try:
# Python 3.0 +
import http.client as httplib
except ImportError:
# Python 2.7 and earlier
import httplib
try:
# Python 2.6 +
from hashlib import sha as sha
except ImportError:
# Python 2.5 and earlier
import sha
__author__ = "Ralph-Gordon Paul, Adrian Cowan"
__credits__ = ["Ralph-Gordon Paul", "Adrian Cowan", "Justin Nemeth", "Sean Rudford"]
__license__ = "GPL"
__maintainer__ = "Ralph-Gordon Paul"
__email__ = "[email protected]"
__status__ = "Production"
# read settings
__settings__ = xbmcaddon.Addon( "script.traktutilities" )
__language__ = __settings__.getLocalizedString
apikey = '0a698a20b222d0b8637298f6920bf03a'
username = __settings__.getSetting("username")
pwd = sha.new(__settings__.getSetting("password")).hexdigest()
debug = __settings__.getSetting( "debug" )
https = __settings__.getSetting('https')
if (https == 'true'):
conn = httplib.HTTPSConnection('api.trakt.tv')
else:
conn = httplib.HTTPConnection('api.trakt.tv')
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
def showTrendingMovies():
movies = getTrendingMoviesFromTrakt()
watchlist = traktMovieListByImdbID(getWatchlistMoviesFromTrakt())
if movies == None: # movies = None => there was an error
return # error already displayed in utilities.py
if len(movies) == 0:
xbmcgui.Dialog().ok("Trakt Utilities", "there are no trending movies")
return
for movie in movies:
if movie['imdb_id'] in watchlist:
movie['watchlist'] = True
else:
movie['watchlist'] = False
# display trending movie list
import windows
ui = windows.MoviesWindow("movies.xml", __settings__.getAddonInfo('path'), "Default")
ui.initWindow(movies, 'trending')
ui.doModal()
del ui
def showTrendingTVShows():
tvshows = getTrendingTVShowsFromTrakt()
watchlist = traktShowListByTvdbID(getWatchlistTVShowsFromTrakt())
if tvshows == None: # tvshows = None => there was an error
return # error already displayed in utilities.py
if len(tvshows) == 0:
xbmcgui.Dialog().ok("Trakt Utilities", "there are no trending tv shows")
return
for tvshow in tvshows:
if tvshow['imdb_id'] in watchlist:
tvshow['watchlist'] = True
else:
tvshow['watchlist'] = False
# display trending tv shows
import windows
ui = windows.TVShowsWindow("tvshows.xml", __settings__.getAddonInfo('path'), "Default")
ui.initWindow(tvshows, 'trending')
ui.doModal()
del ui