Exemplo n.º 1
0
	def run(self):
		Debug("[Notification] Starting")
		
		# setup event driven classes
		self.Player = traktPlayer(action = self._dispatch)
		self.Monitor = traktMonitor(action = self._dispatch)
		
		# init traktapi class
		globals.traktapi = traktAPI()

		# initalize scrobbler class
		self._scrobbler = Scrobbler(globals.traktapi)

		# start loop for events
		while (not xbmc.abortRequested):
			xbmc.sleep(500)
			
		# we aborted
		if xbmc.abortRequested:
			Debug("[Notification] abortRequested received, shutting down.")
			
			# delete player/monitor
			del self.Player
			del self.Monitor
			
			# join scrobbler, to wait for termination
			Debug("[Notification] Joining scrobbler thread to wait for exit.")
			self._scrobbler.join()
Exemplo n.º 2
0
    def run(self):
        startup_delay = utilities.getSettingAsInt('startup_delay')
        if startup_delay:
            utilities.Debug("Delaying startup by %d seconds." % startup_delay)
            xbmc.sleep(startup_delay * 1000)

        utilities.Debug("Service thread starting.")

        # setup event driven classes
        self.Player = traktPlayer(action=self._dispatchQueue)
        self.Monitor = traktMonitor(action=self._dispatchQueue)

        # init traktapi class
        globals.traktapi = traktAPI()

        # init sync thread
        self.syncThread = syncThread()

        # init scrobbler class
        self.scrobbler = Scrobbler(globals.traktapi)

        # init tagging class
        self.tagger = Tagger(globals.traktapi)

        # purge queue
        self.dispatchQueue.purge()

        # start loop for events
        while (not xbmc.abortRequested):
            while len(self.dispatchQueue) and (not xbmc.abortRequested):
                data = self.dispatchQueue.get()
                utilities.Debug("Queued dispatch: %s" % data)
                self._dispatch(data)

            if xbmc.Player().isPlayingVideo():
                self.scrobbler.update()

            xbmc.sleep(500)

        # we are shutting down
        utilities.Debug("Beginning shut down.")

        # check if watcher is set and active, if so, cancel it.
        if self.watcher:
            if self.watcher.isAlive():
                self.watcher.cancel()

        # delete player/monitor
        del self.Player
        del self.Monitor

        # check update tags thread.
        if self.updateTagsThread and self.updateTagsThread.isAlive():
            self.updateTagsThread.join()

        # check if sync thread is running, if so, join it.
        if self.syncThread.isAlive():
            self.syncThread.join()
Exemplo n.º 3
0
	def run(self):
		startup_delay = utilities.getSettingAsInt('startup_delay')
		if startup_delay:
			utilities.Debug("Delaying startup by %d seconds." % startup_delay)
			xbmc.sleep(startup_delay * 1000)

		utilities.Debug("Service thread starting.")
		
		# setup event driven classes
		self.Player = traktPlayer(action = self._dispatchQueue)
		self.Monitor = traktMonitor(action = self._dispatchQueue)

		# init traktapi class
		globals.traktapi = traktAPI()

		# init sync thread
		self.syncThread = syncThread()

		# init scrobbler class
		self.scrobbler = Scrobbler(globals.traktapi)

		# start loop for events
		while (not xbmc.abortRequested):
			while not self.dispatchQueue.empty() and (not xbmc.abortRequested):
				data = self.dispatchQueue.get()
				utilities.Debug("Queued dispatch: %s" % data)
				self._dispatch(data)

			# check if we were tasked to do a manual sync
			if utilities.getPropertyAsBool('traktManualSync'):
				if not self.syncThread.isAlive():
					utilities.Debug("Performing a manual sync.")
					self.doSync(manual=True)
				else:
					utilities.Debug("There already is a sync in progress.")

				utilities.clearProperty('traktManualSync')

			if xbmc.Player().isPlayingVideo():
				self.scrobbler.update()

			xbmc.sleep(500)

		# we are shutting down
		utilities.Debug("Beginning shut down.")

		# check if watcher is set and active, if so, cancel it.
		if self.watcher:
			if self.watcher.isAlive():
				self.watcher.cancel()

		# delete player/monitor
		del self.Player
		del self.Monitor

		# check if sync thread is running, if so, join it.
		if self.syncThread.isAlive():
			self.syncThread.join()
Exemplo n.º 4
0
	def run(self):
		startup_delay = utilities.getSettingAsInt('startup_delay')
		if startup_delay:
			utilities.Debug("Delaying startup by %d seconds." % startup_delay)
			xbmc.sleep(startup_delay * 1000)

		utilities.Debug("Service thread starting.")

		# setup event driven classes
		self.Player = traktPlayer(action = self._dispatchQueue)
		self.Monitor = traktMonitor(action = self._dispatchQueue)

		# init traktapi class
		globals.traktapi = traktAPI()

		# init sync thread
		self.syncThread = syncThread()

		# init scrobbler class
		self.scrobbler = Scrobbler(globals.traktapi)

		# init tagging class
		self.tagger = Tagger(globals.traktapi)
		
		# purge queue
		self.dispatchQueue.purge()

		# start loop for events
		while (not xbmc.abortRequested):
			while len(self.dispatchQueue) and (not xbmc.abortRequested):
				data = self.dispatchQueue.get()
				utilities.Debug("Queued dispatch: %s" % data)
				self._dispatch(data)

			if xbmc.Player().isPlayingVideo():
				self.scrobbler.update()

			xbmc.sleep(500)

		# we are shutting down
		utilities.Debug("Beginning shut down.")

		# check if watcher is set and active, if so, cancel it.
		if self.watcher:
			if self.watcher.isAlive():
				self.watcher.cancel()

		# delete player/monitor
		del self.Player
		del self.Monitor

		# check update tags thread.
		if self.updateTagsThread and self.updateTagsThread.isAlive():
			self.updateTagsThread.join()

		# check if sync thread is running, if so, join it.
		if self.syncThread.isAlive():
			self.syncThread.join()
Exemplo n.º 5
0
 def __get_token(self):
     pin = self.pin_edit_control.getText().strip()
     if pin:
         try:
             if traktapi.traktAPI().authenticate(pin):
                 return True
         except:
             return False
     return False
Exemplo n.º 6
0
 def __get_token(self):
     pin = self.pin_edit_control.getText().strip()
     if pin:
         try:
             if traktapi.traktAPI().authenticate(pin):
                 return True
         except:
             return False
     return False
Exemplo n.º 7
0
    def run(self):
        startup_delay = kodiUtilities.getSettingAsInt('startup_delay')
        if startup_delay:
            logger.debug("Delaying startup by %d seconds." % startup_delay)
            xbmc.sleep(startup_delay * 1000)

        logger.debug("Service thread starting.")

        # purge queue before doing anything
        self.dispatchQueue.purge()

        # setup event driven classes
        self.Player = traktPlayer(action=self._dispatchQueue)
        self.Monitor = traktMonitor(action=self._dispatchQueue)

        # init traktapi class
        globals.traktapi = traktAPI()

        # init sync thread
        self.syncThread = syncThread()

        # init scrobbler class
        self.scrobbler = Scrobbler(globals.traktapi)

        AddonSignals.registerSlot('service.nextup.notification', 'NEXTUPWATCHEDSIGNAL', self.callback)

        # start loop for events
        while not self.Monitor.abortRequested():
            if not kodiUtilities.getSetting('authorization'):
                last_reminder = kodiUtilities.getSettingAsInt('last_reminder')
                now = int(time.time())
                if last_reminder >= 0 and last_reminder < now - (24 * 60 * 60):
                    gui_utils.get_pin()
                
            while len(self.dispatchQueue) and (not self.Monitor.abortRequested()):
                data = self.dispatchQueue.get()
                logger.debug("Queued dispatch: %s" % data)
                self._dispatch(data)

            if xbmc.Player().isPlayingVideo():
                self.scrobbler.transitionCheck()

            if self.Monitor.waitForAbort(1):
                # Abort was requested while waiting. We should exit
                break

        # we are shutting down
        logger.debug("Beginning shut down.")

        # delete player/monitor
        del self.Player
        del self.Monitor

        # check if sync thread is running, if so, join it.
        if self.syncThread.isAlive():
            self.syncThread.join()
Exemplo n.º 8
0
    def run(self):
        startup_delay = utilities.getSettingAsInt('startup_delay')
        if startup_delay:
            logger.debug("Delaying startup by %d seconds." % startup_delay)
            xbmc.sleep(startup_delay * 1000)

        logger.debug("Service thread starting.")

        # purge queue before doing anything
        self.dispatchQueue.purge()

        # setup event driven classes
        self.Player = traktPlayer(action=self._dispatchQueue)
        self.Monitor = traktMonitor(action=self._dispatchQueue)

        # init traktapi class
        globals.traktapi = traktAPI()

        # init sync thread
        self.syncThread = syncThread()

        # init scrobbler class
        self.scrobbler = Scrobbler(globals.traktapi)

        # start loop for events
        while not self.Monitor.abortRequested():
            if not utilities.getSetting('authorization'):
                last_reminder = utilities.getSettingAsInt('last_reminder')
                now = int(time.time())
                if last_reminder >= 0 and last_reminder < now - (24 * 60 * 60):
                    gui_utils.get_pin()

            while len(self.dispatchQueue) and (
                    not self.Monitor.abortRequested()):
                data = self.dispatchQueue.get()
                logger.debug("Queued dispatch: %s" % data)
                self._dispatch(data)

            if xbmc.Player().isPlayingVideo():
                self.scrobbler.transitionCheck()

            if self.Monitor.waitForAbort(1):
                # Abort was requested while waiting. We should exit
                break

        # we are shutting down
        logger.debug("Beginning shut down.")

        # delete player/monitor
        del self.Player
        del self.Monitor

        # check if sync thread is running, if so, join it.
        if self.syncThread.isAlive():
            self.syncThread.join()
Exemplo n.º 9
0
 def _dispatch(self, data):
     try:
         logger.debug("Dispatch: %s" % data)
         action = data['action']
         if action == 'started':
             del data['action']
             self.scrobbler.playbackStarted(data)
         elif action == 'ended' or action == 'stopped':
             self.scrobbler.playbackEnded()
         elif action == 'paused':
             self.scrobbler.playbackPaused()
         elif action == 'resumed':
             self.scrobbler.playbackResumed()
         elif action == 'seek' or action == 'seekchapter':
             self.scrobbler.playbackSeek()
         elif action == 'scanFinished':
             if kodiUtilities.getSettingAsBool('sync_on_update'):
                 logger.debug("Performing sync after library update.")
                 self.doSync()
         elif action == 'databaseCleaned':
             if kodiUtilities.getSettingAsBool('sync_on_update') and (
                     kodiUtilities.getSettingAsBool('clean_trakt_movies') or
                     kodiUtilities.getSettingAsBool('clean_trakt_episodes')
             ):
                 logger.debug("Performing sync after library clean.")
                 self.doSync()
         elif action == 'markWatched':
             del data['action']
             self.doMarkWatched(data)
         elif action == 'manualRating':
             ratingData = data['ratingData']
             self.doManualRating(ratingData)
         elif action == 'addtowatchlist':  # add to watchlist
             del data['action']
             self.doAddToWatchlist(data)
         elif action == 'manualSync':
             if not self.syncThread.isAlive():
                 logger.debug("Performing a manual sync.")
                 self.doSync(manual=True,
                             silent=data['silent'],
                             library=data['library'])
             else:
                 logger.debug("There already is a sync in progress.")
         elif action == 'settings':
             kodiUtilities.showSettings()
         elif action == 'auth_info':
             xbmc.executebuiltin('Dialog.Close(all, true)')
             # init traktapi class
             globals.traktapi = traktAPI(True)
         else:
             logger.debug("Unknown dispatch action, '%s'." % action)
     except Exception as ex:
         message = utilities.createError(ex)
         logger.fatal(message)
Exemplo n.º 10
0
    def run(self):
        startup_delay = utilities.getSettingAsInt('startup_delay')
        if startup_delay:
            logger.debug("Delaying startup by %d seconds." % startup_delay)
            xbmc.sleep(startup_delay * 1000)

        logger.debug("Service thread starting.")

        # purge queue before doing anything
        self.dispatchQueue.purge()

        # setup event driven classes
        self.Player = traktPlayer(action=self._dispatchQueue)
        self.Monitor = traktMonitor(action=self._dispatchQueue)

        # init traktapi class
        globals.traktapi = traktAPI()

        # init sync thread
        self.syncThread = syncThread()

        # init scrobbler class
        self.scrobbler = Scrobbler(globals.traktapi)

        # start loop for events
        while not xbmc.abortRequested:
            if not utilities.getSetting('authorization'):
                last_reminder = utilities.getSettingAsInt('last_reminder')
                now = int(time.time())
                if last_reminder >= 0 and last_reminder < now - (24 * 60 * 60):
                    gui_utils.get_pin()
                
            while len(self.dispatchQueue) and (not xbmc.abortRequested):
                data = self.dispatchQueue.get()
                logger.debug("Queued dispatch: %s" % data)
                self._dispatch(data)

            if xbmc.Player().isPlayingVideo():
                self.scrobbler.transitionCheck()

            xbmc.sleep(500)

        # we are shutting down
        logger.debug("Beginning shut down.")

        # delete player/monitor
        del self.Player
        del self.Monitor

        # check if sync thread is running, if so, join it.
        if self.syncThread.isAlive():
            self.syncThread.join()
Exemplo n.º 11
0
    def run(self):
        startup_delay = kodiUtilities.getSettingAsInt('startup_delay')
        if startup_delay:
            logger.debug("Delaying startup by %d seconds." % startup_delay)
            xbmc.sleep(startup_delay * 1000)

        logger.debug("Service thread starting.")

        # purge queue before doing anything
        self.dispatchQueue.purge()

        # setup event driven classes
        self.Player = traktPlayer(action=self._dispatchQueue)
        self.Monitor = traktMonitor(action=self._dispatchQueue)

        # init traktapi class
        globals.traktapi = traktAPI()

        # init sync thread
        self.syncThread = syncThread()

        # init scrobbler class
        self.scrobbler = Scrobbler(globals.traktapi)

        AddonSignals.registerSlot('service.nextup.notification',
                                  'NEXTUPWATCHEDSIGNAL', self.callback)

        # start loop for events
        while not self.Monitor.abortRequested():
            while len(self.dispatchQueue) and (
                    not self.Monitor.abortRequested()):
                data = self.dispatchQueue.get()
                logger.debug("Queued dispatch: %s" % data)
                self._dispatch(data)

            if xbmc.Player().isPlayingVideo():
                self.scrobbler.transitionCheck()

            if self.Monitor.waitForAbort(1):
                # Abort was requested while waiting. We should exit
                break

        # we are shutting down
        logger.debug("Beginning shut down.")

        # delete player/monitor
        del self.Player
        del self.Monitor

        # check if sync thread is running, if so, join it.
        if self.syncThread.isAlive():
            self.syncThread.join()
Exemplo n.º 12
0
	def __init__(self, show_progress=False, api=None):
		self.traktapi = api
		if self.traktapi == None:
			from traktapi import traktAPI
			self.traktapi = traktAPI()
			
		self.xbmc_shows = []
		self.trakt_shows = {'collection': [], 'watched': []}
		self.notify = __setting__('show_sync_notifications') == 'true'
		self.show_progress = show_progress

		if self.show_progress:
			progress.create('%s %s' % (__getstring__(1400), __getstring__(1406)), line1=' ', line2=' ', line3=' ')
Exemplo n.º 13
0
	def __init__(self, show_progress=False, api=None):
		self.traktapi = api
		if self.traktapi == None:
			from traktapi import traktAPI
			self.traktapi = traktAPI()

		self.xbmc_movies = None
		self.trakt_movies_seen = None
		self.trakt_movies_collection = None
		self.show_progress = show_progress
		self.notify = __setting__('show_sync_notifications') == 'true'

		if self.show_progress:
			progress.create('%s %s' % (__getstring__(1400), __getstring__(1402)), line1=' ', line2=' ', line3=' ')
Exemplo n.º 14
0
 def _dispatch(self, data):
     try:
         logger.debug("Dispatch: %s" % data)
         action = data['action']
         if action == 'started':
             del data['action']
             self.scrobbler.playbackStarted(data)
         elif action == 'ended' or action == 'stopped':
             self.scrobbler.playbackEnded()
         elif action == 'paused':
             self.scrobbler.playbackPaused()
         elif action == 'resumed':
             self.scrobbler.playbackResumed()
         elif action == 'seek' or action == 'seekchapter':
             self.scrobbler.playbackSeek()
         elif action == 'scanFinished':
             if kodiUtilities.getSettingAsBool('sync_on_update'):
                 logger.debug("Performing sync after library update.")
                 self.doSync()
         elif action == 'databaseCleaned':
             if kodiUtilities.getSettingAsBool('sync_on_update') and (kodiUtilities.getSettingAsBool('clean_trakt_movies') or kodiUtilities.getSettingAsBool('clean_trakt_episodes')):
                 logger.debug("Performing sync after library clean.")
                 self.doSync()
         elif action == 'markWatched':
             del data['action']
             self.doMarkWatched(data)
         elif action == 'manualRating':
             ratingData = data['ratingData']
             self.doManualRating(ratingData)
         elif action == 'addtowatchlist':  # add to watchlist
             del data['action']
             self.doAddToWatchlist(data)
         elif action == 'manualSync':
             if not self.syncThread.isAlive():
                 logger.debug("Performing a manual sync.")
                 self.doSync(manual=True, silent=data['silent'], library=data['library'])
             else:
                 logger.debug("There already is a sync in progress.")
         elif action == 'settings':
             kodiUtilities.showSettings()
         elif action == 'auth_info':
             xbmc.executebuiltin('Dialog.Close(all, true)')
             # init traktapi class
             globals.traktapi = traktAPI(True)
         else:
             logger.debug("Unknown dispatch action, '%s'." % action)
     except Exception as ex:
         message = utilities.createError(ex)
         logger.fatal(message)
Exemplo n.º 15
0
    def run(self):
        startup_delay = utilities.getSettingAsInt('startup_delay')
        if startup_delay:
            logger.debug("Delaying startup by %d seconds." % startup_delay)
            xbmc.sleep(startup_delay * 1000)

        logger.debug("Service thread starting.")

        # purge queue before doing anything
        self.dispatchQueue.purge()

        # setup event driven classes
        self.Player = traktPlayer(action=self._dispatchQueue)
        self.Monitor = traktMonitor(action=self._dispatchQueue)

        # init traktapi class
        globals.traktapi = traktAPI()

        # init sync thread
        self.syncThread = syncThread()

        # init scrobbler class
        self.scrobbler = Scrobbler(globals.traktapi)

        # start loop for events
        while not xbmc.abortRequested:
            while len(self.dispatchQueue) and (not xbmc.abortRequested):
                data = self.dispatchQueue.get()
                logger.debug("Queued dispatch: %s" % data)
                self._dispatch(data)

            if xbmc.Player().isPlayingVideo():
                self.scrobbler.transitionCheck()

            xbmc.sleep(500)

        # we are shutting down
        logger.debug("Beginning shut down.")

        # delete player/monitor
        del self.Player
        del self.Monitor

        # check if sync thread is running, if so, join it.
        if self.syncThread.isAlive():
            self.syncThread.join()
Exemplo n.º 16
0
def run(ump):
    globals()["ump"] = ump
    tapi = traktapi.traktAPI()
def run(ump):
	globals()["ump"]=ump
	tapi=traktapi.traktAPI()