diff --git a/default.py b/default.py index 3d8f246..c02cbfd 100644 --- a/default.py +++ b/default.py @@ -24,6 +24,7 @@ from resources.lib.tvtime import FindEpisode from resources.lib.tvtime import MarkAsWatched +from resources.lib.tvtime import Follow from resources.lib.tvtime import MarkAsUnWatched from resources.lib.tvtime import GetUserInformations from resources.lib.tvtime import SaveProgress @@ -173,12 +174,21 @@ def _player_onstop(self, data): if actual_percent <= 90: return - log('MarkAsWatched(*, %s, %s, %s)' % (player.filename, player.facebook, player.twitter)) - checkin = MarkAsWatched(player.token, player.episode.id, player.facebook, player.twitter) + log('MarkAsWatched(*, %s, %s, %s, %s)' % (player.filename, player.facebook, player.twitter, player.autofollow)) + checkin = MarkAsWatched(player.token, player.episode.id, player.facebook, player.twitter, player.autofollow) log('checkin.is_marked:=%s' % checkin.is_marked) if not checkin.is_marked: return + # this is just temporary fix because TVTime's Checkin API is not working correctly + # auto_follow parameter is not working, if tvtime fixes this issue we can remove this piece of code + try: + if player.autofollow: + log("following tvshow manually=%s" % player.episode.showid) + Follow(player.token, player.episode.showid) + except: + pass + if player.emotion == 'true': msg = '%s: %s %sx%s' % (__language__(33909), player.episode.showname, player.episode.season_number, player.episode.number) emotion = xbmcgui.Dialog().select(msg, [__language__(35311), __language__(35312), __language__(35313), __language__(35314), __language__(35316), __language__(35317)]) @@ -257,9 +267,19 @@ def _video_onupdate(self, data): return if playcount == 1: - log('MarkAsWatched(*, %s, %s, %s)' % (self.filename, player.facebook, player.twitter)) - checkin = MarkAsWatched(player.token, self.episode.id, player.facebook, player.twitter) + log('MarkAsWatched(*, %s, %s, %s, %s)' % (self.filename, player.facebook, player.twitter, player.autofollow)) + checkin = MarkAsWatched(player.token, self.episode.id, player.facebook, player.twitter, player.autofollow) log('checkin.is_marked:=%s' % checkin.is_marked) + + # this is just temporary fix because TVTime's Checkin API is not working correctly + # auto_follow parameter is not working, if tvtime fixes this issue we can remove this piece of code + try: + if player.autofollow: + log("following tvshow manually=%s" % self.episode.showid) + Follow(player.token, self.episode.showid) + except: + pass + if checkin.is_marked: if player.emotion == 'true': emotion = xbmcgui.Dialog().select('%s: %s' % (__language__(33909), self.filename), [__language__(35311), __language__(35312), __language__(35313), __language__(35314), __language__(35316), __language__(35317)]) @@ -353,6 +373,7 @@ def __init__ (self): self.welcome = __addon__.getSetting('welcome') self.notifications = __addon__.getSetting('notifications') self.notif_during_playback = __addon__.getSetting('notif_during_playback') + self.autofollow = __addon__.getSetting('autofollow') self.notif_scrobbling = __addon__.getSetting('notif_scrobbling') self.progress = __addon__.getSetting('progress') self.http = __addon__.getSetting('http') diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po index d612b77..77fcba9 100644 --- a/resources/language/English/strings.po +++ b/resources/language/English/strings.po @@ -41,6 +41,10 @@ msgctxt "#32303" msgid "Mark the http streams" msgstr "" +msgctxt "#32304" +msgid "Auto-follow the show if not already followed" +msgstr "" + msgctxt "#33001" msgid "Notifications" msgstr "" diff --git a/resources/language/French/strings.po b/resources/language/French/strings.po index 6b9aa0b..c9ecc71 100644 --- a/resources/language/French/strings.po +++ b/resources/language/French/strings.po @@ -41,6 +41,10 @@ msgctxt "#32303" msgid "Mark the http streams" msgstr "Marquer les flux http" +msgctxt "#32304" +msgid "Auto-follow the show if not already followed" +msgstr "Suivre automatiquement le spectacle s'il n'est pas déjà suivi" + msgctxt "#33001" msgid "Notifications" msgstr "Notifications" diff --git a/resources/language/Italian/strings.po b/resources/language/Italian/strings.po index e464264..99d5dc4 100644 --- a/resources/language/Italian/strings.po +++ b/resources/language/Italian/strings.po @@ -41,6 +41,10 @@ msgctxt "#32303" msgid "Mark the http streams" msgstr "Segna i flussi http" +msgctxt "#32304" +msgid "Auto-follow the show if not already followed" +msgstr "Segui automaticamente lo show se non è già seguito" + msgctxt "#33001" msgid "Notifications" msgstr "Notifiche" diff --git a/resources/lib/tvtime.py b/resources/lib/tvtime.py index c799715..5d2f74f 100644 --- a/resources/lib/tvtime.py +++ b/resources/lib/tvtime.py @@ -45,6 +45,7 @@ def __init__(self, token, episode_id, filename=''): else: self.is_found = True self.resultdata = data['result'] + self.showid = data['episode']['show']['id'] self.showname = data['episode']['show']['name'] self.episodename = data['episode']['name'] self.season_number = data['episode']['season_number'] @@ -170,10 +171,8 @@ def __init__(self, token, episode_id, facebook=0, twitter=0, autofollow=1): else: self.twitter = 0 self.autofollow = autofollow - if self.autofollow == True: self.autofollow = 1 - else: self.autofollow = 0 - self.action = 'checkin' + request_data = urllib.parse.urlencode({ 'access_token' : self.token, 'episode_id' : self.episode_id, @@ -206,7 +205,7 @@ def __init__(self, token, episode_id, facebook=0, twitter=0, autofollow=1): self.is_marked = False else: self.is_marked = True - + class MarkAsUnWatched(object): def __init__(self, token, episode_id): self.token = token diff --git a/resources/settings.xml b/resources/settings.xml index 9452c15..1c65674 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -5,6 +5,7 @@ +