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
/
Copy pathfriends.py
99 lines (81 loc) · 3.73 KB
/
friends.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 xbmc,xbmcaddon,xbmcgui
from utilities import *
__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 showFriends():
options = []
data = getFriendsFromTrakt()
if data == None: # data = None => there was an error
return # error already displayed in utilities.py
for friend in data:
try:
if friend['full_name'] != None:
options.append(friend['full_name']+" ("+friend['username']+")")
else:
options.append(friend['username'])
except KeyError:
pass # Error ? skip this movie
if len(options) == 0:
xbmcgui.Dialog().ok("Trakt Utilities", "you have not added any friends on Trakt")
return
while True:
select = xbmcgui.Dialog().select(__language__(1211).encode( "utf-8", "ignore" ), options) # Friends
Debug("Select: " + str(select))
if select == -1:
Debug ("menu quit by user")
return
showFriendSubmenu(data[select])
def showFriendSubmenu(user):
#check what (if anything) the user is watching
watchdata = getWatchingFromTraktForUser(user['username'])
currentitem = "Nothing"
if len(watchdata) != 0:
if watchdata['type'] == "movie":
currentitem = watchdata['movie']['title']+" ["+str(watchdata['movie']['year'])+"]"
elif watchdata['type'] == "episode":
currentitem = watchdata['show']['title']+" "+str(watchdata['episode']['season'])+"x"+str(watchdata['episode']['number'])+" - "+watchdata['episode']['title']
options = [(__language__(1280)+": "+currentitem).encode( "utf-8", "ignore" ), __language__(1281).encode( "utf-8", "ignore" ), __language__(1282).encode( "utf-8", "ignore" ), __language__(1283).encode( "utf-8", "ignore" ), __language__(1284).encode( "utf-8", "ignore" )]
while True:
select = xbmcgui.Dialog().select((__language__(1211)+" - "+user['username']).encode( "utf-8", "ignore" ), options)
Debug("Select: " + str(select))
if select == -1:
Debug ("menu quit by user")
return
else:
if select == 0: # Select (friends) currenty playing
xbmcgui.Dialog().ok("Trakt Utilities", "comming soon")
elif select == 1: # Friends watchlist
showFriendsWatchlist(user)
elif select == 2: # Friends watched
showFriendsWatched(user)
elif select == 3: # Friends library
showFriendsLibrary(user)
elif select == 4: # Friends profile
showFriendsProfile(user)
def showFriendsWatchlist(user):
xbmcgui.Dialog().ok("Trakt Utilities", "comming soon")
def showFriendsWatched(user):
xbmcgui.Dialog().ok("Trakt Utilities", "comming soon")
def showFriendsLibrary(user):
xbmcgui.Dialog().ok("Trakt Utilities", "comming soon")
def showFriendsProfile(user):
xbmcgui.Dialog().ok("Trakt Utilities", "comming soon")