Esempio n. 1
0
    def keepPlaybackAlive(self):
        pname = '%s.player.overlay' % control.addonInfo('id')
        control.window.clearProperty(pname)


        if self.content == 'movie':
            overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(), self.imdb)

        elif self.content == 'episode':
            overlay = playcount.getEpisodeOverlay(playcount.getTVShowIndicators(), self.imdb, self.tvdb, self.season, self.episode)

        else:
            overlay = '6'


        for i in range(0, 240):
            if self.isPlayingVideo(): break
            xbmc.sleep(1000)


        if overlay == '7':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()
                except:
                    pass
                xbmc.sleep(2000)


        elif self.content == 'movie':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()

                    watcher = (self.currentTime / self.totalTime >= .9)
                    property = control.window.getProperty(pname)

                    if watcher == True and not property == '7':
                        control.window.setProperty(pname, '7')
                        playcount.markMovieDuringPlayback(self.imdb, '7')

                    elif watcher == False and not property == '6':
                        control.window.setProperty(pname, '6')
                        playcount.markMovieDuringPlayback(self.imdb, '6')
                except:
                    pass
                xbmc.sleep(2000)


        elif self.content == 'episode':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()

                    watcher = (self.currentTime / self.totalTime >= .9)
                    property = control.window.getProperty(pname)

                    if watcher == True and not property == '7':
                        control.window.setProperty(pname, '7')
                        playcount.markEpisodeDuringPlayback(self.imdb, self.tvdb, self.season, self.episode, '7')

                    elif watcher == False and not property == '6':
                        control.window.setProperty(pname, '6')
                        playcount.markEpisodeDuringPlayback(self.imdb, self.tvdb, self.season, self.episode, '6')
                except:
                    pass
                xbmc.sleep(2000)


        control.window.clearProperty(pname)
Esempio n. 2
0
    def keepAlive(self):
        pname = '%s.player.overlay' % control.addonInfo('id')
        control.window.clearProperty(pname)

        if self.media_type == 'movie':
            overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(),
                                                self.imdb)

        elif self.media_type == 'episode':
            overlay = playcount.getEpisodeOverlay(
                playcount.getTVShowIndicators(), self.imdb, self.tvdb,
                self.season, self.episode)
        else:
            overlay = '6'

        for i in range(0, 240):
            if self.isPlayback():
                break
            xbmc.sleep(1000)

        while self.isPlayingVideo():
            try:
                if not self.playback_started:
                    xbmc.sleep(1000)
                    continue

                if not self.playback_started:
                    self.start_playback()

                try:
                    self.current_time = self.getTime()
                    self.media_length = self.getTotalTime()
                except:
                    pass

                watcher = (self.getWatchedPercent() >= 80)
                property = control.window.getProperty(pname)

                if self.media_type == 'movie':
                    try:
                        # if watcher is True and property != '7':
                        if watcher and property != '7':
                            control.window.setProperty(pname, '7')
                            playcount.markMovieDuringPlayback(self.imdb, '7')
                        # elif watcher is False and property != '6':
                        # control.window.setProperty(pname, '6')
                        # playcount.markMovieDuringPlayback(self.imdb, '6')
                    except:
                        continue
                    xbmc.sleep(2000)

                elif self.media_type == 'episode':
                    try:
                        # if watcher is True and property != '7':
                        if watcher and property != '7':
                            control.window.setProperty(pname, '7')
                            playcount.markEpisodeDuringPlayback(
                                self.imdb, self.tvdb, self.season,
                                self.episode, '7')
                        # elif watcher is False and property != '6':
                        # control.window.setProperty(pname, '6')
                        # playcount.markEpisodeDuringPlayback(self.imdb, self.tvdb, self.season, self.episode, '6')
                    except:
                        continue
                    xbmc.sleep(2000)

            except:
                log_utils.error()
                xbmc.sleep(1000)
                continue

        control.window.clearProperty(pname)
Esempio n. 3
0
    def keepPlaybackAlive(self):
        pname = '%s.player.overlay' % control.addonInfo('id')
        control.window.clearProperty(pname)

        if self.content == 'movie':
            overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(),
                                                self.imdb)

        elif self.content == 'episode':
            overlay = playcount.getEpisodeOverlay(
                playcount.getTVShowIndicators(), self.imdb, self.tvdb,
                self.season, self.episode)

        else:
            overlay = '6'

        for i in range(0, 240):
            if self.isPlayingVideo(): break
            xbmc.sleep(1000)

        if overlay == '7':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()
                except:
                    pass
                xbmc.sleep(2000)

        elif self.content == 'movie':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()

                    watcher = (self.currentTime / self.totalTime >= .9)
                    property = control.window.getProperty(pname)

                    if watcher == True and not property == '7':
                        control.window.setProperty(pname, '7')
                        playcount.markMovieDuringPlayback(self.imdb, '7')

                    elif watcher == False and not property == '6':
                        control.window.setProperty(pname, '6')
                        playcount.markMovieDuringPlayback(self.imdb, '6')
                except:
                    pass
                xbmc.sleep(2000)

        elif self.content == 'episode':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()

                    watcher = (self.currentTime / self.totalTime >= .9)
                    property = control.window.getProperty(pname)

                    if watcher == True and not property == '7':
                        control.window.setProperty(pname, '7')
                        playcount.markEpisodeDuringPlayback(
                            self.imdb, self.tvdb, self.season, self.episode,
                            '7')

                    elif watcher == False and not property == '6':
                        control.window.setProperty(pname, '6')
                        playcount.markEpisodeDuringPlayback(
                            self.imdb, self.tvdb, self.season, self.episode,
                            '6')
                except:
                    pass
                xbmc.sleep(2000)

        control.window.clearProperty(pname)
Esempio n. 4
0
    def keepPlaybackAlive(self):
        self._downloadCheck()

        pname = '%s.player.overlay' % control.addonInfo('id')
        control.window.clearProperty(pname)

        if self.content == 'movie':
            overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(),
                                                self.imdb)
        elif self.content == 'episode':
            overlay = playcount.getEpisodeOverlay(
                playcount.getTVShowIndicators(), self.imdb, self.tvdb,
                self.season, self.episode)
        else:
            overlay = '6'

        dots = ''
        title = ''
        message = ''
        background = False
        progressDialog = None

        title = interface.Translation.string(33451)
        message = interface.Translation.string(33452)
        message = interface.Format.fontBold(message)
        background = tools.Settings.getInteger(
            'interface.stream.progress') == 1
        interface.Loader.hide()
        progressDialog = interface.Dialog.progress(background=background,
                                                   title=title,
                                                   message=message)

        timeout = 90  # 60 too little for slow connections, eg over VPN.
        for i in range(0, timeout):
            if self.isPlayingVideo(): break
            if self.download == None:
                try:
                    canceled = progressDialog.iscanceled()
                except:
                    canceled = False
                if canceled: break

                label = message + ' ' + dots
                dots += '.'
                if len(dots) > 3: dots = ''

                progress = 50 + int(
                    (i / float(timeout)) * 50
                )  # Only half the progress, since the other half is from sources __init__.py.
                if background: progressDialog.update(progress, title, label)
                else: progressDialog.update(progress, label)
            else:
                self._downloadCheck()
            xbmc.sleep(500)

        try:
            canceled = progressDialog.iscanceled()
        except:
            canceled = False

        try:
            if not canceled:
                progressDialog.update(
                    100, ''
                )  # Must be set to 100 for background dialog, otherwise it shows up in a later dialog.
        except:
            pass

        try:
            progressDialog.close()
        except:
            pass

        if canceled:
            self.stop()
            return

        # Kodi often starts playback where isPlaying() is true and isPlayingVideo() is false, since the video loading is still in progress, whereas the play is already started.
        # Only show the notification if the player is not able to load the file at all.
        if not self.isPlaying() and not self.isPlayingVideo():
            interface.Dialog.notification(title=33448,
                                          message=33450,
                                          icon=interface.Dialog.IconError)

        # NB: Overlay is 7 when movie stopped and resumed, causing the movie to be never added to Trakt.
        '''if overlay == '7':

			while self.isPlayingVideo():
				try:
					self.totalTime = self.getTotalTime()
					self.currentTime = self.getTime()
				except:
					pass

				if self.download == None:
					xbmc.sleep(2000)
				else:
					for i in range(4):
						self._downloadCheck()
						xbmc.sleep(500)


		elif self.content == 'movie':'''
        if self.content == 'movie':
            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()

                    watcher = (self.currentTime / self.totalTime >= .8)
                    property = control.window.getProperty(pname)

                    if watcher == True and not property == '7':
                        control.window.setProperty(pname, '7')
                        playcount.markMovieDuringPlayback(self.imdb, '7')

                    elif watcher == False and not property == '6':
                        control.window.setProperty(pname, '6')
                        playcount.markMovieDuringPlayback(self.imdb, '6')
                except:
                    pass

                if self.download == None:
                    xbmc.sleep(2000)
                else:
                    for i in range(4):
                        self._downloadCheck()
                        xbmc.sleep(500)

        elif self.content == 'episode':

            while self.isPlayingVideo():
                try:
                    self.totalTime = self.getTotalTime()
                    self.currentTime = self.getTime()

                    watcher = (self.currentTime / self.totalTime >= .8)
                    property = control.window.getProperty(pname)

                    if watcher == True and not property == '7':
                        control.window.setProperty(pname, '7')
                        playcount.markEpisodeDuringPlayback(
                            self.imdb, self.tvdb, self.season, self.episode,
                            '7')

                    elif watcher == False and not property == '6':
                        control.window.setProperty(pname, '6')
                        playcount.markEpisodeDuringPlayback(
                            self.imdb, self.tvdb, self.season, self.episode,
                            '6')
                except:
                    pass

                if self.download == None:
                    xbmc.sleep(2000)
                else:
                    for i in range(4):
                        self._downloadCheck()
                        xbmc.sleep(500)

        control.window.clearProperty(pname)
Esempio n. 5
0
	def keepPlaybackAlive(self):
		from resources.lib.extensions import core
		self._downloadCheck()

		pname = '%s.player.overlay' % control.addonInfo('id')
		control.window.clearProperty(pname)

		if self.typeMovie:
			overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(), self.idImdb)
		elif self.typeTelevision:
			overlay = playcount.getEpisodeOverlay(playcount.getTVShowIndicators(), self.idImdb, self.idTvdb, self.seasonString, self.episodeString)
		else:
			overlay = '6'

		title = interface.Translation.string(33451)
		status = interface.Translation.string(33452)
		substatus1 = interface.Translation.string(35474)
		substatus2 = interface.Translation.string(35303)
		message = self.progressMessage
		if not message == '':
			if interface.Core.background() and not self.core.progressPlaybackEnabled():
				message += ' - '
			else:
				message += '.' + interface.Format.newline()
		message += status
		interface.Loader.hide()

		self.core.progressPlaybackInitialize(title = title, message = message, metadata = self.metadata)
		timeout = tools.Settings.getInteger('general.playback.timeout')

		# Use a thread for Kodi 18, since the player freezes for a few seconds before starting playback.
		thread = threading.Thread(target = self.keepPlaybackWait, args = (title, message, status, substatus1, substatus2, timeout))
		thread.start()
		thread.join()

		if self.core.progressPlaybackCanceled():
			self.core.progressPlaybackClose()
			self.stop()
			self._debridClear()
			return True

		# Only show the notification if the player is not able to load the file at all.
		if not self.isPlayback():
			self.stop()
			self.core.progressPlaybackUpdate(progress = 100, message = '', status = None) # Must be set to 100 for background dialog, otherwise it shows up in a later dialog.
			control.window.clearProperty(pname)
			return False

		#self.core.progressPlaybackClose()
		addLibrary = tools.Settings.getBoolean('library.updates.watched')
		playbackEnd = tools.Settings.getInteger('general.playback.end') / 100.0

		streamsHas = False
		visibleWas = False

		while self.isPlayingVideo():
			try:
				self.timeTotal = self.getTotalTime()
				self.timeCurrent = self.getTime()

				watcher = (self.timeCurrent / self.timeTotal >= playbackEnd)
				property = control.window.getProperty(pname)

				if watcher == True and not property == '7':
					try: orionoid.Orionoid().streamVote(idItem = self.source['orion']['item'], idStream = self.source['orion']['stream'], vote = orionoid.Orionoid.VoteUp)
					except: pass
					control.window.setProperty(pname, '7')
					if self.typeMovie:
						playcount.markMovieDuringPlayback(self.idImdb, '7')
						if addLibrary: library.Library(type = self.type).add(title = self.title, year = self.year, imdb = self.imdb, tmdb = self.tmdb, metadata = self.metadata)
					else:
						playcount.markEpisodeDuringPlayback(self.idImdb, self.idTvdb, self.seasonString, self.episodeString, '7')
						if addLibrary: library.Library(type = self.type).add(title = self.title, year = self.year, imdb = self.imdb, tvdb = self.tvdb, metadata = self.metadata)
				elif watcher == False and not property == '6':
					control.window.setProperty(pname, '6')
					# Gaia
					# Do not mark as unwatched, otherwise if the video was previously watched and later rewatched, if will mark it as unwatched when played the second time.
					# Trakt can set multiple watches so that you can track on how many times you watched something.
					#playcount.markMovieDuringPlayback(self.idImdb, '6')
					#playcount.markEpisodeDuringPlayback(self.idImdb, self.idTvdb, self.seasonString, self.episodeString, '6')
			except:
				pass

			if self.navigationStreamsSpecial:
				for i in range(4):
					visible = self.isVisible()
					playback = self.isPlayback()
					if not visibleWas and visible: visibleWas = True
					if not streamsHas and playback and visibleWas and not visible:
						streamsHas = True
						self._showStreams()
					elif streamsHas and visible:
						streamsHas = False
						interface.Dialog.closeAll()
					if not self.download == None: self._downloadCheck()
					xbmc.sleep(1000)
			else:
				if self.download == None:
					xbmc.sleep(2000)
				else:
					for i in range(4):
						self._downloadCheck()
						xbmc.sleep(500)

		control.window.clearProperty(pname)
		return True
Esempio n. 6
0
 def keepAlive(self):
     pname = '%s.player.overlay' % control.addonInfo('id')
     control.homeWindow.clearProperty(pname)
     if self.media_type == 'movie':
         overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(),
                                             self.imdb)
     elif self.media_type == 'episode':
         overlay = playcount.getEpisodeOverlay(
             playcount.getTVShowIndicators(), self.imdb, self.tvdb,
             self.season, self.episode)
     else:
         overlay = '4'
     for i in range(0, 240):
         if self.isPlayback():
             control.closeAll()
             break
         xbmc.sleep(1000)
     while self.isPlayingVideo():
         try:
             if control.monitor.abortRequested(): return sysexit()
             try:
                 self.current_time = self.getTime()
                 self.media_length = self.getTotalTime()
             except:
                 pass
             watcher = (self.getWatchedPercent() >= 80)
             property = control.homeWindow.getProperty(pname)
             if self.media_type == 'movie':
                 try:
                     if watcher and property != '5':
                         control.homeWindow.setProperty(pname, '5')
                         playcount.markMovieDuringPlayback(self.imdb, '5')
                 except:
                     pass
                 xbmc.sleep(2000)
             elif self.media_type == 'episode':
                 try:
                     if watcher and property != '5':
                         control.homeWindow.setProperty(pname, '5')
                         playcount.markEpisodeDuringPlayback(
                             self.imdb, self.tvdb, self.season,
                             self.episode, '5')
                     if self.enable_playnext and not self.play_next_triggered:
                         if int(control.playlist.size()) > 1:
                             if self.preScrape_triggered == False:
                                 xbmc.executebuiltin(
                                     'RunPlugin(plugin://plugin.video.dg/?action=play_preScrapeNext)'
                                 )
                                 self.preScrape_triggered = True
                             remaining_time = self.getRemainingTime()
                             if remaining_time < (self.playnext_time + 1
                                                  ) and remaining_time != 0:
                                 xbmc.executebuiltin(
                                     'RunPlugin(plugin://plugin.video.dg/?action=play_nextWindowXML)'
                                 )
                                 self.play_next_triggered = True
                 except:
                     log_utils.error()
                     pass
                 xbmc.sleep(1000)
         except:
             log_utils.error()
             xbmc.sleep(1000)
     control.homeWindow.clearProperty(pname)
Esempio n. 7
0
	def keepPlaybackAlive(self):
		self._downloadCheck()

		pname = '%s.player.overlay' % control.addonInfo('id')
		control.window.clearProperty(pname)

		if self.content == 'movie':
			overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(), self.imdb)
		elif self.content == 'episode':
			overlay = playcount.getEpisodeOverlay(playcount.getTVShowIndicators(), self.imdb, self.tvdb, self.season, self.episode)
		else:
			overlay = '6'

		dots = ''
		title = ''
		message = ''
		background = False
		progressDialog = None

		title = interface.Translation.string(33451)
		message = interface.Translation.string(33452)
		message = interface.Format.fontBold(message)
		background = tools.Settings.getInteger('interface.stream.progress') == 1
		interface.Loader.hide()
		progressDialog = interface.Dialog.progress(background = background, title = title, message = message)

		timeout = 90 # 60 too little for slow connections, eg over VPN.
		for i in range(0, timeout):
			if self.isPlayingVideo(): break
			if self.download == None:
				try: canceled = progressDialog.iscanceled()
				except: canceled = False
				if canceled: break

				label = message + ' ' + dots
				dots += '.'
				if len(dots) > 3: dots = ''

				progress = 50 + int((i / float(timeout)) * 50) # Only half the progress, since the other half is from sources __init__.py.
				if background: progressDialog.update(progress, title, label)
				else: progressDialog.update(progress, label)
			else:
				self._downloadCheck()
			xbmc.sleep(500)

		try: canceled = progressDialog.iscanceled()
		except: canceled = False

		try:
			if not canceled:
				progressDialog.update(100, '') # Must be set to 100 for background dialog, otherwise it shows up in a later dialog.
		except: pass

		try: progressDialog.close()
		except: pass

		if canceled:
			self.stop()
			return

		# Kodi often starts playback where isPlaying() is true and isPlayingVideo() is false, since the video loading is still in progress, whereas the play is already started.
		# Only show the notification if the player is not able to load the file at all.
		if not self.isPlaying() and not self.isPlayingVideo():
			interface.Dialog.notification(title = 33448, message = 33450, icon = interface.Dialog.IconError)

		# NB: Overlay is 7 when movie stopped and resumed, causing the movie to be never added to Trakt.
		'''if overlay == '7':

			while self.isPlayingVideo():
				try:
					self.totalTime = self.getTotalTime()
					self.currentTime = self.getTime()
				except:
					pass

				if self.download == None:
					xbmc.sleep(2000)
				else:
					for i in range(4):
						self._downloadCheck()
						xbmc.sleep(500)


		elif self.content == 'movie':'''
		if self.content == 'movie':
			while self.isPlayingVideo():
				try:
					self.totalTime = self.getTotalTime()
					self.currentTime = self.getTime()

					watcher = (self.currentTime / self.totalTime >= .8)
					property = control.window.getProperty(pname)

					if watcher == True and not property == '7':
						control.window.setProperty(pname, '7')
						playcount.markMovieDuringPlayback(self.imdb, '7')

					elif watcher == False and not property == '6':
						control.window.setProperty(pname, '6')
						playcount.markMovieDuringPlayback(self.imdb, '6')
				except:
					pass

				if self.download == None:
					xbmc.sleep(2000)
				else:
					for i in range(4):
						self._downloadCheck()
						xbmc.sleep(500)


		elif self.content == 'episode':

			while self.isPlayingVideo():
				try:
					self.totalTime = self.getTotalTime()
					self.currentTime = self.getTime()

					watcher = (self.currentTime / self.totalTime >= .8)
					property = control.window.getProperty(pname)

					if watcher == True and not property == '7':
						control.window.setProperty(pname, '7')
						playcount.markEpisodeDuringPlayback(self.imdb, self.tvdb, self.season, self.episode, '7')

					elif watcher == False and not property == '6':
						control.window.setProperty(pname, '6')
						playcount.markEpisodeDuringPlayback(self.imdb, self.tvdb, self.season, self.episode, '6')
				except:
					pass

				if self.download == None:
					xbmc.sleep(2000)
				else:
					for i in range(4):
						self._downloadCheck()
						xbmc.sleep(500)


		control.window.clearProperty(pname)
Esempio n. 8
0
    def keepAlive(self):
        pname = '%s.player.overlay' % control.addonInfo('id')
        control.window.clearProperty(pname)

        if self.media_type == 'movie':
            overlay = playcount.getMovieOverlay(playcount.getMovieIndicators(),
                                                self.imdb)

        elif self.media_type == 'episode':
            overlay = playcount.getEpisodeOverlay(
                playcount.getTVShowIndicators(), self.imdb, self.tvdb,
                self.season, self.episode)
        else:
            overlay = '6'

        if self.playback_resumed is True:
            self.offset = '0'

        for i in range(0, 240):
            if self.isPlayback(): break
            xbmc.sleep(1000)

        while self.isPlayingVideo():
            try:
                if not self.playback_started:
                    xbmc.sleep(1000)
                    continue

                if not self.playback_started:
                    self.start_playback()

                if not self.offset == '0' and self.playback_resumed is False:
                    # if not self.offset == '0':
                    # from resources.lib.modules import log_utils
                    # log_utils.log2("Seeking %s seconds" % self.offset, 'info')
                    self.seekTime(float(self.offset))
                    self.offset = '0'
                    self.playback_resumed = True

                try:
                    self.current_time = self.getTime()
                    self.media_length = self.getTotalTime()
                except:
                    pass

                watcher = (self.getWatchedPercent() >= 90)
                property = control.window.getProperty(pname)

                if self.media_type == 'movie':
                    try:
                        if watcher is True and not property == '7':
                            control.window.setProperty(pname, '7')
                            playcount.markMovieDuringPlayback(self.imdb, '7')
                        elif watcher is False and not property == '6':
                            control.window.setProperty(pname, '6')
                            playcount.markMovieDuringPlayback(self.imdb, '6')
                    except:
                        import traceback
                        traceback.print_exc()
                        continue

                elif self.media_type == 'episode':
                    try:
                        if watcher is True and not property == '7':
                            control.window.setProperty(pname, '7')
                            playcount.markEpisodeDuringPlayback(
                                self.imdb, self.tvdb, self.season,
                                self.episode, '7')
                        elif watcher is False and not property == '6':
                            control.window.setProperty(pname, '6')
                            playcount.markEpisodeDuringPlayback(
                                self.imdb, self.tvdb, self.season,
                                self.episode, '6')
                    except:
                        import traceback
                        traceback.print_exc()
                        continue

            except:
                import traceback
                traceback.print_exc()
                xbmc.sleep(1000)
                continue

            xbmc.sleep(3000)

        control.window.clearProperty(pname)
        self.onPlayBackEnded()