Skip to content

Commit

Permalink
Added autofollow
Browse files Browse the repository at this point in the history
  • Loading branch information
panizza committed Mar 22, 2021
1 parent 9eb1bf2 commit 49eaaea
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 8 deletions.
29 changes: 25 additions & 4 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)])
Expand Down Expand Up @@ -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)])
Expand Down Expand Up @@ -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')
Expand Down
4 changes: 4 additions & 0 deletions resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
4 changes: 4 additions & 0 deletions resources/language/French/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions resources/language/Italian/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions resources/lib/tvtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<setting id="user" type="text" label="32301" enable="false" />
<setting id="progress" type="bool" label="32302" default="true" />
<setting id="http" type="bool" label="32303" default="false" />
<setting id="autofollow" type="bool" label="32304" default="true" />
</category>
<category label="33001">
<setting id="notifications" type="bool" label="33301" default="true" />
Expand Down

0 comments on commit 49eaaea

Please sign in to comment.