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
/
rating.py
78 lines (65 loc) · 2.91 KB
/
rating.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
# -*- coding: utf-8 -*-
#
import os
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" )
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}
def ratingCheck(curVideo, watchedTime, totalTime, playlistLength):
__settings__ = xbmcaddon.Addon( "script.traktutilities" ) #read settings again, encase they have changed
# you can disable rating in options
rateMovieOption = __settings__.getSetting("rate_movie")
rateEpisodeOption = __settings__.getSetting("rate_episode")
rateEachInPlaylistOption = __settings__.getSetting("rate_each_playlist_item")
rateMinViewTimeOption = __settings__.getSetting("rate_min_view_time")
if (watchedTime/totalTime)*100>=float(rateMinViewTimeOption):
if (playlistLength <= 1) or (rateEachInPlaylistOption == 'true'):
if curVideo['type'] == 'movie' and rateMovieOption == 'true':
doRateMovie(curVideo['id'])
if curVideo['type'] == 'episode' and rateEpisodeOption == 'true':
doRateEpisode(curVideo['id'])
# ask user if they liked the movie
def doRateMovie(movieid=None, imdbid=None, title=None, year=None):
if (movieid <> None) :
match = getMovieDetailsFromXbmc(movieid, ['imdbnumber','title','year'])
if not match:
#add error message here
return
imdbid = match['imdbnumber']
title = match['title']
year = match['year']
# display rate dialog
import windows
ui = windows.RateMovieDialog("rate.xml", __settings__.getAddonInfo('path'), "Default")
ui.initDialog(imdbid, title, year, getMovieRatingFromTrakt(imdbid, title, year))
ui.doModal()
del ui
# ask user if they liked the episode
def doRateEpisode(episodeId):
match = getEpisodeDetailsFromXbmc(episodeId, ['showtitle', 'season', 'episode'])
if not match:
#add error message here
return
tvdbid = None #match['tvdbnumber']
title = match['showtitle']
year = None #match['year']
season = match['season']
episode = match['episode']
# display rate dialog
import windows
ui = windows.RateEpisodeDialog("rate.xml", __settings__.getAddonInfo('path'), "Default")
ui.initDialog(tvdbid, title, year, season, episode, getEpisodeRatingFromTrakt(tvdbid, title, year, season, episode))
ui.doModal()
del ui