diff --git a/addon.xml b/addon.xml
new file mode 100644
index 0000000..03ef04b
--- /dev/null
+++ b/addon.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+ Are you sleeping? Stop the playback!
+ Adormeceste? Pára a stream!
+ This service addon makes Kodi stop any playback if it exceeds a given playback time. If you have that awful habit of leaving Kodi playing live content after you fell asleep, this addon is for you!
+ Este service addon faz com que o Kodi pare qualquer playback se o seu tempo exceder um valor fornecido. Se tiver aquele estranho hábito de adormecer enquanto o Kodi está a reproduzir conteúdo ao vivo, este addon é para si!
+ all
+ GNU GENERAL PUBLIC LICENSE. Version 2, June 1991
+
+
diff --git a/icon.png b/icon.png
new file mode 100644
index 0000000..8181f22
Binary files /dev/null and b/icon.png differ
diff --git a/resources/settings.xml b/resources/settings.xml
new file mode 100644
index 0000000..2607836
--- /dev/null
+++ b/resources/settings.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/service.py b/service.py
new file mode 100644
index 0000000..b87f814
--- /dev/null
+++ b/service.py
@@ -0,0 +1,71 @@
+#!/usr/bin/python
+import time
+import datetime
+import xbmc
+import xbmcplugin
+import xbmcgui
+import xbmcaddon
+import xbmcvfs
+
+addon_id = 'service.safestop'
+selfAddon = xbmcaddon.Addon(id=addon_id)
+datapath = xbmc.translatePath(selfAddon.getAddonInfo('profile')).decode('utf-8')
+addonfolder = xbmc.translatePath(selfAddon.getAddonInfo('path')).decode('utf-8')
+msgok = xbmcgui.Dialog().ok
+mensagemprogresso = xbmcgui.DialogProgress()
+
+debug=selfAddon.getSetting('debug_mode')
+check_time = int(selfAddon.getSetting('check_time'))
+max_time = int(selfAddon.getSetting('max_time'))
+time_to_wait = int(selfAddon.getSetting('waiting_time_dialog'))
+
+class service:
+ def __init__(self):
+ intro = False
+ while not xbmc.abortRequested:
+ if not intro:
+ print "service.safestop"
+ print "Service started..."
+ intro = True
+
+ if xbmc.Player().isPlaying():
+ playback_time = xbmc.Player().getTime()
+ if int(playback_time)/(60*60) >= max_time:
+ if debug == 'true':
+ print "service.safestop: Time exceeds max allowed. Stopping the stream"
+ ret = mensagemprogresso.create('Safe Stop')
+ secs=0
+ percent=0
+ increment = int(100 / time_to_wait)
+ cancelled = False
+ while secs < time_to_wait:
+ secs = secs + 1
+ percent = increment*secs
+ secs_left = str((time_to_wait - secs))
+ remaining_display = str(secs_left) + " seconds left."
+ mensagemprogresso.update(percent,"Cancel to continue watching",remaining_display)
+ xbmc.sleep(1000)
+ if (mensagemprogresso.iscanceled()):
+ cancelled = True
+ break
+ if cancelled == True:
+ check_time = int(selfAddon.getSetting('check_time_next'))
+ else:
+ mensagemprogresso.close()
+ xbmc.Player().stop()
+ else:
+ check_time = int(selfAddon.getSetting('check_time'))
+ if debug == 'true':
+ print "service.safestop: Playing the stream, time does not exceed max limit"
+
+ else:
+ if debug == 'true':
+ print "service.safestrop: Not playing any media file"
+ check_time = int(selfAddon.getSetting('check_time'))
+
+
+ xbmc.sleep(check_time*60*1000)
+
+service()
+
+