Skip to content
54 changes: 13 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,25 @@
script.tvtime
=================
# script.tvtime

Kodi plugin for [TV Time](http://www.tvtime.com)

This plugin will set TV shows episodes you've seen as watched on TV Time.
It will also add the new TV show to your account if it was not already there.

install
=======
This fork has been created to be able to apply some fixes on the initial repository (hibernating/dead) but it will never be submitted to the official Kodi repository.
Please follow Build or Download steps below to install this version.

This plugin has been submitted to the [official Kodi repository](http://addons.xbmc.org/show/script.tvtime/).
To install it, just follow this [HOW-TO](http://kodi.wiki/view/HOW-TO:Install_add-ons).
After that, launch the add-on to login.
## Build

build
=====
If you want to build it manually, please follow the steps below:

If you want to build it manually, here is a simple script to do so:
```sh
#!/bin/bash
1. Clone this repository `sudo git clone https://github.com/alxlaxv/script.tvtime.git`
2. Enter in script.tvtime `cd script.tvtime`
3. Make the compile script executable `sudo chmod +x compile.sh`
4. Launch the compile script `./compile.sh`

dest=script.tvtime
version=$(grep -E "^\s+version" addon.xml | cut -f2 -d'"')
It will create a zip file which can be installed directly within Kodi by following this [HOW-TO](https://kodi.wiki/view/Add-on_manager#How_to_install_from_a_ZIP_file).

if [ -d $dest ]; then
rm -r $dest
fi
## Download

mkdir $dest
cp addon.xml $dest/
cp *.txt $dest/
cp icon.png $dest/
cp *.py $dest/
cp -r resources $dest/

if [ -f $dest-$version.zip ]; then
rm $dest-$version.zip
fi

zip -r $dest-$version.zip $dest
rm -r $dest
````
It will create a zip file that you can install directly within Kodi.
Using the GUI of Kodi, choose to install your plugin as a zip file, find your zip file and it's done !

download
========

If you want to download the release package because you can't or don't want to build it, you can do it on this link:
http://addons.xbmc.org/show/script.tvtime/
or
[download](here) the latests version.
You can down the [last release](https://github.com/alxlaxv/script.tvtime/releases/latest) directly.
It will download a zip file which can be installed directly within Kodi by following this [HOW-TO](https://kodi.wiki/view/Add-on_manager#How_to_install_from_a_ZIP_file).
10 changes: 5 additions & 5 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.tvtime"
name="TV Time"
version="1.2.0"
provider-name="CXII">
version="1.2.3"
provider-name="alxlaxv">
<requires>
<import addon="xbmc.python" version="2.19.0"/>
</requires>
Expand All @@ -19,9 +19,9 @@
<language>en fr it</language>
<license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
<forum>http://forum.kodi.tv/showthread.php?tid=199604</forum>
<website>https://github.com/cxii-dev/script.tvtime</website>
<source>https://github.com/cxii-dev/script.tvtime.git</source>
<email>cxii-dev[AT]users[DOT]noreply[DOT]github[DOT]com</email>
<website>https://github.com/alxlaxv/script.tvtime</website>
<source>https://github.com/alxlaxv/script.tvtime.git</source>
<email>alxlaxv[AT]users[DOT]noreply[DOT]github[DOT]com</email>
</extension>
</addon>

83 changes: 45 additions & 38 deletions default.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def _tearDown(self):
def onSettingsChanged( self ):
log('onSettingsChanged')
self.action()

def onNotification(self, sender, method, data):
log('onNotification')
log('method=%s' % method)
Expand All @@ -90,7 +90,7 @@ def onNotification(self, sender, method, data):
player.episode = FindEpisode(player.token, 0, player.filename)
log('episode.is_found=%s' % player.episode.is_found)
if player.episode.is_found:
if player.notifications == 'true':
if player.notifications == 'true':
if player.notif_during_playback == 'false' and player.isPlaying() == 1:
return
if player.notif_scrobbling == 'false':
Expand All @@ -103,22 +103,22 @@ def onNotification(self, sender, method, data):
notif(__language__(32905), time=2500)
else:
player.http_playing = False
response = json.loads(data)
response = json.loads(data)
log('%s' % response)
if response.get('item').get('type') == 'episode':
xbmc_id = response.get('item').get('id')
item = self.getEpisodeTVDB(xbmc_id)
item = self.getEpisodeTVDB(xbmc_id)
log('showtitle=%s' % item['showtitle'])
log('season=%s' % item['season'])
log('episode=%s' % item['episode'])
log('episode_id=%s' % item['episode_id'])
if len(item['showtitle']) > 0 and item['season'] > 0 and item['episode'] > 0 and item['episode_id'] > 0:
if len(item['showtitle']) > 0 and item['season'] > 0 and item['episode'] > 0 and item['episode_id'] > 0:
player.filename = '%s.S%.2dE%.2d' % (formatName(item['showtitle']), float(item['season']), float(item['episode']))
log('tvshowtitle=%s' % player.filename)
player.episode = FindEpisode(player.token, item['episode_id'])
player.episode = FindEpisode(player.token, item['episode_id'], player.filename)
log('episode.is_found=%s' % player.episode.is_found)
if player.episode.is_found:
if player.notifications == 'true':
if player.notifications == 'true':
if player.notif_during_playback == 'false' and player.isPlaying() == 1:
return
if player.notif_scrobbling == 'false':
Expand All @@ -133,20 +133,20 @@ def onNotification(self, sender, method, data):
if player.notifications == 'true':
if player.notif_during_playback == 'false' and player.isPlaying() == 1:
return
notif(__language__(32905), time=2500)
if (method == 'Player.OnStop'):
notif(__language__(32905), time=2500)
if (method == 'Player.OnStop'):
self._tearDown()
actual_percent = (self._last_pos/self._total_time)*100
log('last_pos / total_time : %s / %s = %s %%' % (self._last_pos, self._total_time, actual_percent))
log('Player.OnStop')
log('last_pos / total_time : %s / %s = %s %%' % (self._last_pos, self._total_time, actual_percent))
log('Player.OnStop')
if player.http == 'true' and player.http_playing == True :
if player.progress == 'true':
player.episode = FindEpisode(player.token, 0, player.filename)
log('episode.is_found=%s' % player.episode.is_found)
if player.episode.is_found:
log('progress=%s' % self._last_pos)
self.progress = SaveProgress(player.token, player.episode.id, self._last_pos)
log('progress.is_set:=%s' % self.progress.is_set)
self.progress = SaveProgress(player.token, player.episode.id, self._last_pos)
log('progress.is_set:=%s' % self.progress.is_set)
if actual_percent > 90:
log('MarkAsWatched(*, %s, %s, %s)' % (player.filename, player.facebook, player.twitter))
checkin = MarkAsWatched(player.token, player.episode.id, player.facebook, player.twitter)
Expand All @@ -173,33 +173,33 @@ def onNotification(self, sender, method, data):
return
if player.notif_scrobbling == 'false':
return
notif('%s %s %sx%s' % (__language__(32906), player.episode.showname, player.episode.season_number, player.episode.number), time=2500)
else:
response = json.loads(data)
notif('%s %s %sx%s' % (__language__(32906), player.episode.showname, player.episode.season_number, player.episode.number), time=2500)
else:
response = json.loads(data)
log('%s' % response)
if player.progress == 'true':
if response.get('item').get('type') == 'episode':
xbmc_id = response.get('item').get('id')
item = self.getEpisodeTVDB(xbmc_id)
item = self.getEpisodeTVDB(xbmc_id)
log('showtitle=%s' % item['showtitle'])
log('season=%s' % item['season'])
log('episode=%s' % item['episode'])
log('episode_id=%s' % item['episode_id'])
if len(item['showtitle']) > 0 and item['season'] > 0 and item['episode'] > 0 and item['episode_id'] > 0:
if len(item['showtitle']) > 0 and item['season'] > 0 and item['episode'] > 0 and item['episode_id'] > 0:
player.filename = '%s.S%.2dE%.2d' % (formatName(item['showtitle']), float(item['season']), float(item['episode']))
log('tvshowtitle=%s' % player.filename)
log('progress=%s' % self._last_pos)
self.progress = SaveProgress(player.token, item['episode_id'], self._last_pos)
log('progress.is_set:=%s' % self.progress.is_set)
self.progress = SaveProgress(player.token, item['episode_id'], self._last_pos)
log('progress.is_set:=%s' % self.progress.is_set)
if (method == 'VideoLibrary.OnUpdate'):
log('VideoLibrary.OnUpdate')
response = json.loads(data)
response = json.loads(data)
log('%s' % response)
if response.get('item').get('type') == 'episode':
xbmc_id = response.get('item').get('id')
playcount = response.get('playcount')
playcount = response.get('playcount')
log('playcount=%s' % playcount)
item = self.getEpisodeTVDB(xbmc_id)
item = self.getEpisodeTVDB(xbmc_id)
log('showtitle=%s' % item['showtitle'])
log('season=%s' % item['season'])
log('episode=%s' % item['episode'])
Expand All @@ -208,12 +208,12 @@ def onNotification(self, sender, method, data):
if len(item['showtitle']) > 0 and item['season'] > 0 and item['episode'] > 0 and item['episode_id'] > 0:
self.filename = '%s.S%.2dE%.2d' % (formatName(item['showtitle']), float(item['season']), float(item['episode']))
log('tvshowtitle=%s' % self.filename)
self.episode = FindEpisode(player.token, item['episode_id'])
self.episode = FindEpisode(player.token, item['episode_id'], self.filename)
log('episode.is_found=%s' % self.episode.is_found)
if self.episode.is_found:
if playcount is 1:
log('MarkAsWatched(*, %s, %s, %s)' % (self.filename, player.facebook, player.twitter))
checkin = MarkAsWatched(player.token, item['episode_id'], player.facebook, player.twitter)
checkin = MarkAsWatched(player.token, self.episode.id, player.facebook, player.twitter)
log('checkin.is_marked:=%s' % checkin.is_marked)
if checkin.is_marked:
if player.emotion == 'true':
Expand All @@ -231,7 +231,7 @@ def onNotification(self, sender, method, data):
self.emotion = 6
elif self.emotion == 5:
self.emotion = 7
SetEmotion(player.token, item['episode_id'], self.emotion)
SetEmotion(player.token, self.episode.id, self.emotion)
if player.notifications == 'true':
if player.notif_during_playback == 'false' and player.isPlaying() == 1:
return
Expand All @@ -245,7 +245,7 @@ def onNotification(self, sender, method, data):
notif(__language__(32907), time=2500)
if playcount is 0:
log('MarkAsUnWatched(*, %s)' % (self.filename))
checkin = MarkAsUnWatched(player.token, item['episode_id'])
checkin = MarkAsUnWatched(player.token, self.episode.id)
log('checkin.is_unmarked:=%s' % checkin.is_unmarked)
if checkin.is_unmarked:
if player.notifications == 'true':
Expand All @@ -264,21 +264,29 @@ def getEpisodeTVDB(self, xbmc_id):
rpccmd = {'jsonrpc': '2.0', 'method': 'VideoLibrary.GetEpisodeDetails', 'params': {"episodeid": int(xbmc_id), 'properties': ['season', 'episode', 'tvshowid', 'showtitle', 'uniqueid']}, 'id': 1}
rpccmd = json.dumps(rpccmd)
result = xbmc.executeJSONRPC(rpccmd)
result = json.loads(result)
log('result=%s' % result)
log('episode_id=%s' % result['result']['episodedetails']['uniqueid']['unknown'])

result = json.loads(result)
log('result=%s' % result)
if 'unknown' in result['result']['episodedetails']['uniqueid']:
episode_id = result['result']['episodedetails']['uniqueid']['unknown']
elif 'tvdb' in result['result']['episodedetails']['uniqueid']:
episode_id = result['result']['episodedetails']['uniqueid']['tvdb']
elif 'tmdb' in result['result']['episodedetails']['uniqueid']:
episode_id = result['result']['episodedetails']['uniqueid']['tmdb']
else:
return False
log('episode_id=%s' % episode_id)

try:
item = {}
item['season'] = result['result']['episodedetails']['season']
item['tvshowid'] = result['result']['episodedetails']['tvshowid']
item['episode'] = result['result']['episodedetails']['episode']
item['showtitle'] = result['result']['episodedetails']['showtitle']
item['episode_id'] = result['result']['episodedetails']['uniqueid']['unknown']
item['episode_id'] = episode_id
return item
except:
return False

def getAllEpisodes(self, xbmc_id):
rpccmd = {'jsonrpc': '2.0', 'method': 'VideoLibrary.GetEpisodes', 'params': {"tvshowid": int(xbmc_id), 'properties': ['season', 'episode', 'showtitle', 'playcount']}, 'id': 1}
rpccmd = json.dumps(rpccmd)
Expand Down Expand Up @@ -313,10 +321,10 @@ def __init__ (self):
return
self._monitor = Monitor(action = self._reset)
log('Player - monitor')

def _reset(self):
self.__init__()

def _GetUser(self):
log('_GetUser')
user = GetUserInformations(self.token)
Expand All @@ -335,12 +343,12 @@ def formatNumber(number):
if len(number) < 2:
number = '0%s' % number
return number

def formatName(filename):
filename = filename.strip()
filename = filename.replace(' ', '.')
return normalizeString(filename)

def notif(msg, time=5000):
xbmcgui.Dialog().notification(encode(__scriptname__), encode(msg), time=time, icon=__icon__)

Expand All @@ -367,4 +375,3 @@ def normalizeString(str):
player._monitor = None
log("sys.exit(0)")
sys.exit(0)

8 changes: 4 additions & 4 deletions resources/language/French/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -91,23 +91,23 @@ msgstr "Bien"

msgctxt "#35312"
msgid "Funk"
msgstr "Fun"
msgstr "Drole"

msgctxt "#35313"
msgid "Wow"
msgstr "Wow"

msgctxt "#35314"
msgid "Sad"
msgstr "triste"
msgstr "Triste"

msgctxt "#35316"
msgid "Soso"
msgstr "Mitigé"
msgstr "Bof"

msgctxt "#35317"
msgid "Bad"
msgstr "Mauvais"
msgstr "Nul"

msgctxt "#32901"
msgid "Please login"
Expand Down