Пример #1
0
def download(info, path, template='%(title)s-%(id)s.%(ext)s'):
    """
    Download the selected video in vidinfo to path.
    Template sets the youtube-dl format which defaults to TITLE-ID.EXT.
    Returns a DownloadResult object.
    """
    info = _convertInfo(info)  # Get the right format
    _completeInfo(info)  # Make sure we have the needed bits

    _cancelDownload(_cancel=False)
    path_template = os.path.join(path, template)
    ytdl = YoutubeDLWrapper._getYTDL()
    ytdl._lastDownloadedFilePath = ''
    ytdl.params['quiet'] = True
    ytdl.params['outtmpl'] = path_template
    import AddonSignals
    signalPayload = {
        'title': info.get('title'),
        'url': info.get('url'),
        'download.ID': info.get('download.ID')
    }
    try:
        AddonSignals.sendSignal('download.started',
                                signalPayload,
                                sourceID='script.module.youtube.dl')
        YoutubeDLWrapper.download(info)
    except YoutubeDLWrapper.youtube_dl.DownloadError, e:
        return DownloadResult(False,
                              e.message,
                              filepath=ytdl._lastDownloadedFilePath)
Пример #2
0
    def start_playback(self):
        try:
            if self.playback_started: return
            if not self.isPlayback(): return
            self.playback_started = True
            self.current_time = self.getTime()
            self.media_length = self.getTotalTime()

            if self.media_type == 'episode' and control.setting(
                    'enable.upnext') == 'true':
                if int(control.playlist.getposition()) == -1:
                    control.playlist.clear()
                    return
                source_id = 'plugin.video.venom'
                return_id = 'plugin.video.venom_play_action'
                try:
                    if int(control.playlist.getposition()) < (
                            control.playlist.size() - 1):
                        if self.media_type is None: return
                        next_info = self.next_info()
                        AddonSignals.sendSignal('upnext_data', next_info,
                                                source_id)
                        AddonSignals.registerSlot('upnextprovider', return_id,
                                                  self.signals_callback)
                        # # Prescrape
                        # from resources.lib.modules import sources
                        # psources = sources.Sources().preScrape(title=next_info['next_episode']['title'], year=next_info['next_episode']['year'], imdb=next_info['next_episode']['tvshowimdb'], tvdb=next_info['next_episode']['tvshowid'], season=next_info['next_episode']['season'], episode=next_info['next_episode']['episode'], tvshowtitle=next_info['next_episode']['showtitle'], premiered=next_info['next_episode']['firstaired'])
                except:
                    log_utils.error()
        except:
            log_utils.error()
 def on_playback_started(self, player_state):  # pylint: disable=unused-argument
     if self.upnext_info:
         LOG.debug('Sending initialization signal to Up Next Add-on')
         import AddonSignals
         AddonSignals.sendSignal(source_id=G.ADDON_ID,
                                 signal='upnext_data',
                                 data=self.upnext_info)
Пример #4
0
    def start_playback(self):
        try:
            tools.execute('Dialog.Close(all,true)')
            self.current_time = self.getTime()
            self.media_length = self.getTotalTime()

            if self.offset is not None and int(self.offset) != 0:
                tools.log("Seeking %s seconds" % self.offset, 'info')
                self.seekTime(self.offset)
                self.offset = None
            else:
                tools.log("No seeking applied")

            self.traktStartWatching()
            if 'episodeInfo' in self.args and tools.getSetting('smartplay.upnext') == 'true':
                source_id = 'plugin.video.%s' % tools.addonName.lower()
                return_id = 'plugin.video.%s_play_action' % tools.addonName.lower()

                try:
                    next_info = self.next_info()
                    AddonSignals.sendSignal('upnext_data', next_info, source_id=source_id)
                    AddonSignals.registerSlot('upnextprovider', return_id, self.signals_callback)
                except:
                    import traceback
                    traceback.print_exc()
                    pass

            if tools.getSetting('general.smartplay') is not 'false' and self.media_type is 'episode':
                if int(tools.playList.getposition()) == (tools.playList.size() - 1):
                    self.next_season = smartPlay.SmartPlay(self.args).append_next_season()

            self.playback_started = True
        except:
            pass
Пример #5
0
    def onPlayBackStarted(self):

        try:
            tools.execute('Dialog.Close(all,true)')
            self.current_time = self.getTime()
            self.media_length = self.getTotalTime()

            if self.offset is not None and int(self.offset) != 0:
                tools.log("Seeking %s seconds" % self.offset, 'info')
                self.seekTime(self.offset)
                self.offset = None
            else:
                tools.log("No seeking applied")

            self.traktStartWatching()
            if 'episodeInfo' in self.args and tools.getSetting(
                    'smartplay.upnext') == 'true':
                source_id = 'plugin.video.%s' % tools.addonName.lower()
                return_id = 'plugin.video.%s_play_action' % tools.addonName.lower(
                )

                try:
                    next_info = self.next_info()
                    AddonSignals.sendSignal('upnext_data',
                                            next_info,
                                            source_id=source_id)
                    AddonSignals.registerSlot('upnextprovider', return_id,
                                              self.signals_callback)
                except:
                    import traceback
                    traceback.print_exc()
                    pass
        except:
            pass
Пример #6
0
    def registerUpNext(self):
        source_id = 'plugin.video.%s' % tools.addonName.lower()
        return_id = 'plugin.video.%s_play_action' % tools.addonName.lower()

        try:
            next_info = self.next_info()
            AddonSignals.registerSlot('upnextprovider', return_id, self.signals_callback)
            AddonSignals.sendSignal('upnext_data', next_info, source_id=source_id)

        except RuntimeError:
            pass

        except:
            import traceback
            traceback.print_exc()
            pass
Пример #7
0
    def send_signal_worker(cls, signal, data=None, source_id=None):
        # type: (str, Any, str) -> None
        """

        :param signal:
        :param data:
        :param source_id:
        :return:
        """
        if PluginBridge._logger.isEnabledFor(LazyLogger.DEBUG_EXTRA_VERBOSE):
            PluginBridge._logger.debug_extra_verbose('signal:', signal,
                                                     'source_id:', source_id)
        Monitor.throw_exception_if_abort_requested()

        try:
            AddonSignals.sendSignal(signal, data=data, source_id=source_id)
        except Exception as e:
            cls._logger.exception(e)
Пример #8
0
    def play_video(self, torrent_url):
        """
        Start the torrent's download and play it while being downloaded
        :param torrent_url: str
        :return: None
        """

        xbmc.log(
            'PeertubeAddon: Starting torrent download ({0})'.format(
                torrent_url), xbmc.LOGDEBUG)

        # Start a downloader thread
        AddonSignals.sendSignal('start_download', {'url': torrent_url})

        # Wait until the PeerTubeDownloader has downloaded all the torrent's metadata
        AddonSignals.registerSlot('plugin.video.peertube',
                                  'metadata_downloaded',
                                  self.play_video_continue)
        timeout = 0
        while self.play == 0 and timeout < 10:
            xbmc.sleep(1000)
            timeout += 1

        # Abort in case of timeout
        if timeout == 10:
            xbmcgui.Dialog().notification('Download timeout',
                                          'Timeout fetching ' + torrent_url,
                                          xbmcgui.NOTIFICATION_ERROR)
            return None
        else:
            # Wait a little before starting playing the torrent
            xbmc.sleep(3000)

        # Pass the item to the Kodi player for actual playback.
        xbmc.log(
            'PeertubeAddon: Starting video playback ({0})'.format(torrent_url),
            xbmc.LOGDEBUG)
        play_item = xbmcgui.ListItem(path=self.torrent_f)
        xbmcplugin.setResolvedUrl(self.plugin_id, True, listitem=play_item)

        return None
Пример #9
0
    def start_playback(self):
        try:
            if self.playback_started:
                return
            if not self.isPlayback():
                return
            self.playback_started = True

            # control.execute('Dialog.Close(all,true)')
            self.current_time = self.getTime()
            self.media_length = self.getTotalTime()

            if self.media_type == 'episode' and control.setting(
                    'enable.upnext') == 'true':
                if int(control.playlist.getposition()) == -1:
                    control.playlist.clear()
                    return
                source_id = 'plugin.video.venom'
                return_id = 'plugin.video.venom_play_action'

                try:
                    # if int(control.playlist.getposition()) < (control.playlist.size() - 1) and not int(control.playlist.getposition()) == -1:
                    if int(control.playlist.getposition()) < (
                            control.playlist.size() - 1):
                        # log_utils.log('playlist.getposition = %s' % int(control.playlist.getposition()), __name__, log_utils.LOGDEBUG)
                        if self.media_type is None:
                            return
                        next_info = self.next_info()
                        AddonSignals.sendSignal('upnext_data', next_info,
                                                source_id)
                        AddonSignals.registerSlot('upnextprovider', return_id,
                                                  self.signals_callback)
                except:
                    import traceback
                    traceback.print_exc()
                    pass

        except:
            import traceback
            traceback.print_exc()
            pass
Пример #10
0
    def run(self):
        """
        Download the torrent specified by self.torrent
        :param: None
        :return: None
        """

        xbmc.log('PeertubeDownloader: Opening bitTorent session',
                 xbmc.LOGDEBUG)
        # Open bitTorrent session
        ses = libtorrent.session()
        ses.listen_on(6881, 6891)

        # Add torrent
        xbmc.log('PeertubeDownloader: Adding torrent ' + self.torrent,
                 xbmc.LOGDEBUG)
        h = ses.add_torrent({'url': self.torrent, 'save_path': self.temp_dir})

        # Set sequential mode to allow watching while downloading
        h.set_sequential_download(True)

        # Download torrent
        xbmc.log('PeertubeDownloader: Downloading torrent ' + self.torrent,
                 xbmc.LOGDEBUG)
        signal_sent = 0
        while not h.is_seed():
            xbmc.sleep(1000)
            s = h.status()
            # Inform addon that all the metadata has been downloaded and that it may start playing the torrent
            if s.state >= 3 and signal_sent == 0:
                xbmc.log(
                    'PeertubeDownloader: Received all torrent metadata, notifying PeertubeAddon',
                    xbmc.LOGDEBUG)
                i = h.torrent_file()
                f = self.temp_dir + i.name()
                AddonSignals.sendSignal('metadata_downloaded', {'file': f})
                signal_sent = 1

        # Everything is done
        return
Пример #11
0
def download(info, path, template='%(title)s-%(id)s.%(ext)s'):
    """
    Download the selected video in vidinfo to path.
    Template sets the youtube-dl format which defaults to TITLE-ID.EXT.
    Returns a DownloadResult object.
    """
    info = _convertInfo(info)  # Get the right format
    _completeInfo(info)  # Make sure we have the needed bits

    _cancelDownload(_cancel=False)
    path_template = os.path.join(path, template)
    ytdl = YoutubeDLWrapper._getYTDL()
    ytdl._lastDownloadedFilePath = ''
    ytdl.params['quiet'] = True
    ytdl.params['outtmpl'] = path_template
    import AddonSignals
    signalPayload = {'title': info.get('title'), 'url': info.get('url'), 'download.ID': info.get('download.ID')}
    try:
        AddonSignals.sendSignal('download.started', signalPayload, sourceID='script.module.youtube.dl')
        YoutubeDLWrapper.download(info)
    except YoutubeDLWrapper.youtube_dl.DownloadError, e:
        return DownloadResult(False, e.message, filepath=ytdl._lastDownloadedFilePath)
Пример #12
0
    def start_playback(self):
        try:
            if self.playback_started:
                return
            if not self.isPlayback():
                return
            self.playback_started = True

            # control.execute('Dialog.Close(all,true)')
            self.current_time = self.getTime()
            self.media_length = self.getTotalTime()

            if self.media_type == 'episode' and control.setting(
                    'enable.upnext') == 'true':
                source_id = 'plugin.video.ego'
                return_id = 'plugin.video.ego_play_action'
                try:
                    if int(control.playlist.getposition()) < (
                            control.playlist.size() - 1):
                        if self.media_type is None:
                            return
                        next_info = self.next_info()
                        # xbmc.log('line 469 next_info = %s' % next_info, 2)
                        AddonSignals.sendSignal('upnext_data', next_info,
                                                source_id)
                        AddonSignals.registerSlot('upnextprovider', return_id,
                                                  self.signals_callback)
                except:
                    import traceback
                    traceback.print_exc()
                    pass

        except:
            import traceback
            traceback.print_exc()
            pass
Пример #13
0
    def autoPlayPlayback(self):
        currentFile = xbmc.Player().getPlayingFile()
        # Get the active player
        result = xbmc.executeJSONRPC(
            '{"jsonrpc": "2.0", "id": 1, "method": "Player.GetActivePlayers"}')
        result = unicode(result, 'utf-8', errors='ignore')
        self.logMsg("Got active player " + result, 2)
        result = json.loads(result)

        # Seems to work too fast loop whilst waiting for it to become active
        while not result["result"]:
            result = xbmc.executeJSONRPC(
                '{"jsonrpc": "2.0", "id": 1, "method": "Player.GetActivePlayers"}'
            )
            result = unicode(result, 'utf-8', errors='ignore')
            self.logMsg("Got active player " + result, 2)
            result = json.loads(result)

        if 'result' in result and result["result"][0] is not None:
            playerid = result["result"][0]["playerid"]

            # Get details of the playing media
            self.logMsg("Getting details of playing media", 1)
            result = xbmc.executeJSONRPC(
                '{"jsonrpc": "2.0", "id": 1, "method": "Player.GetItem", "params": {"playerid": '
                + str(playerid) +
                ', "properties": ["showtitle", "tvshowid", "episode", "season", "playcount"] } }'
            )
            result = unicode(result, 'utf-8', errors='ignore')
            self.logMsg("Got details of playing media" + result, 2)

            result = json.loads(result)
            if 'result' in result:
                itemtype = result["result"]["item"]["type"]

            if self.strm_query(result):
                addonSettings = xbmcaddon.Addon(
                    id='service.nextup.notification')
                playMode = addonSettings.getSetting("autoPlayMode")
                currentepisodenumber = result["result"]["item"]["episode"]
                currentseasonid = result["result"]["item"]["season"]
                currentshowtitle = result["result"]["item"]["showtitle"]
                tvshowid = result["result"]["item"]["tvshowid"]
                shortplayMode = addonSettings.getSetting("shortPlayMode")
                shortplayNotification = addonSettings.getSetting(
                    "shortPlayNotification")
                shortplayLength = int(
                    addonSettings.getSetting("shortPlayLength")) * 60

                if (itemtype == "episode"):
                    # Get the next up episode
                    currentepisodeid = result["result"]["item"]["id"]
                elif tvshowid == -1:
                    # I am a STRM ###
                    tvshowid, episodeid = self.iStream_fix(
                        tvshowid, currentshowtitle, currentepisodenumber,
                        currentseasonid)
                    currentepisodeid = episodeid
                else:
                    # wtf am i doing here error.. ####
                    self.logMsg("Error: cannot determine if episode", 1)
                    return

            self.currentepisodeid = currentepisodeid
            self.logMsg(
                "Getting details of next up episode for tvshow id: " +
                str(tvshowid), 1)
            if self.currenttvshowid != tvshowid:
                self.currenttvshowid = tvshowid
                self.playedinarow = 1

            result = xbmc.executeJSONRPC(
                '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, '
                '"properties": [ "title", "playcount", "season", "episode", "showtitle", "plot", '
                '"file", "rating", "resume", "tvshowid", "art", "firstaired", "runtime", "writer", '
                '"dateadded", "lastplayed" , "streamdetails"], "sort": {"method": "episode"}}, "id": 1}'
                % tvshowid)

            if result:
                result = unicode(result, 'utf-8', errors='ignore')
                result = json.loads(result)
                self.logMsg("Got details of next up episode %s" % str(result),
                            2)
                xbmc.sleep(100)

                # Find the next unwatched and the newest added episodes
                if "result" in result and "episodes" in result["result"]:
                    includeWatched = addonSettings.getSetting(
                        "includeWatched") == "true"
                    episode = self.findNextEpisode(result, currentFile,
                                                   includeWatched)

                    if episode is None:
                        # no episode get out of here
                        return
                    self.logMsg("episode details %s" % str(episode), 2)
                    self.episode = episode
                    episodeid = episode["episodeid"]

                    if includeWatched:
                        includePlaycount = True
                    else:
                        includePlaycount = episode["playcount"] == 0
                    if includePlaycount and currentepisodeid != episodeid:
                        # we have a next up episode
                        self.playbackonended = True
                        self.nextUpPage = NextUpInfo(
                            "script-nextup-notification-NextUpInfo.xml",
                            addonSettings.getAddonInfo('path'), "default",
                            "1080i")
                        self.nextUpPage.setItem(episode)
                        self.stillWatchingPage = StillWatchingInfo(
                            "script-nextup-notification-StillWatchingInfo.xml",
                            addonSettings.getAddonInfo('path'), "default",
                            "1080i")
                        self.stillWatchingPage.setItem(episode)
                        playedinarownumber = addonSettings.getSetting(
                            "playedInARow")
                        playTime = xbmc.Player().getTime()
                        self.totalTime = xbmc.Player().getTotalTime()
                        self.logMsg(
                            "played in a row settings %s" %
                            str(playedinarownumber), 2)
                        self.logMsg(
                            "played in a row %s" % str(self.playedinarow), 2)
                        if int(self.playedinarow) <= int(playedinarownumber):
                            self.logMsg(
                                "showing next up page as played in a row is %s"
                                % str(self.playedinarow), 2)
                            if (shortplayNotification == "false") and (
                                    shortplayLength >= self.totalTime) and (
                                        shortplayMode == "true"):
                                self.logMsg(
                                    "hiding notification for short videos")
                            else:
                                self.nextUpPage.show()
                        else:
                            self.logMsg(
                                "showing still watching page as played in a row %s"
                                % str(self.playedinarow), 2)
                            if (shortplayNotification == "false") and (
                                    shortplayLength >= self.totalTime) and (
                                        shortplayMode == "true"):
                                self.logMsg(
                                    "hiding notification for short videos")
                            else:
                                self.stillWatchingPage.show()
                        while xbmc.Player().isPlaying(
                        ) and not self.nextUpPage.isCancel(
                        ) and not self.nextUpPage.isWatchNow(
                        ) and not self.stillWatchingPage.isStillWatching(
                        ) and not self.stillWatchingPage.isCancel():
                            xbmc.sleep(100)
                            #try:
                            # playTime = xbmc.Player().getTime()
                            #  totalTime = xbmc.Player().getTotalTime()
                            #except:
                            # pass
                        if xbmc.Player().isPlaying():
                            if shortplayLength >= self.totalTime and shortplayMode == "true":
                                #play short video and don't add to playcount
                                self.playedinarow += 0
                                self.logMsg(
                                    "Continuing short video autoplay - %s")
                                if self.nextUpPage.isWatchNow(
                                ) or self.stillWatchingPage.isStillWatching():
                                    self.playedinarow = 1
                                shouldPlayDefault = not self.nextUpPage.isCancel(
                                )
                            else:
                                if int(self.playedinarow) <= int(
                                        playedinarownumber):
                                    self.nextUpPage.close()
                                    shouldPlayDefault = not self.nextUpPage.isCancel(
                                    )
                                    shouldPlayNonDefault = self.nextUpPage.isWatchNow(
                                    )
                                else:
                                    self.stillWatchingPage.close()
                                    shouldPlayDefault = self.stillWatchingPage.isStillWatching(
                                    )
                                    shouldPlayNonDefault = self.stillWatchingPage.isStillWatching(
                                    )

                                if self.nextUpPage.isWatchNow(
                                ) or self.stillWatchingPage.isStillWatching():
                                    self.playedinarow = 1
                                else:
                                    self.playedinarow += 1

                            if (shouldPlayDefault and playMode == "0") or (
                                    shouldPlayNonDefault and playMode == "1"):
                                self.logMsg(
                                    "playing media episode id %s" %
                                    str(episodeid), 2)
                                # Signal to trakt previous episode watched as playback ended early
                                AddonSignals.sendSignal(
                                    "NEXTUPWATCHEDSIGNAL",
                                    {'episodeid': self.currentepisodeid})

                                # Play media
                                xbmc.executeJSONRPC(
                                    '{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", '
                                    '"params": { "item": {"episodeid": ' +
                                    str(episode["episodeid"]) + '} } }')
Пример #14
0
 def stopDownload(self):
     AddonSignals.sendSignal('DOWNLOAD_STOP')
Пример #15
0
                                signalPayload,
                                sourceID='script.module.youtube.dl')
        YoutubeDLWrapper.download(info)
    except YoutubeDLWrapper.youtube_dl.DownloadError, e:
        return DownloadResult(False,
                              e.message,
                              filepath=ytdl._lastDownloadedFilePath)
    except YoutubeDLWrapper.DownloadCanceledException:
        return DownloadResult(False,
                              status='canceled',
                              filepath=ytdl._lastDownloadedFilePath)
    finally:
        ytdl.clearDownloadParams()
        signalPayload['path'] = ytdl._lastDownloadedFilePath
        AddonSignals.sendSignal('download.finished',
                                signalPayload,
                                sourceID='script.module.youtube.dl')

    return DownloadResult(True, filepath=ytdl._lastDownloadedFilePath)


def mightHaveVideo(url, resolve_redirects=False):
    """
    Returns True if the url matches against one of the handled site URLs.
    """
    if resolve_redirects:
        try:
            url = resolve_http_redirect(url)
        except:
            util.ERROR('mightHaveVideo(): Failed to resolve URL')
            return False
Пример #16
0
    ytdl._lastDownloadedFilePath = ''
    ytdl.params['quiet'] = True
    ytdl.params['outtmpl'] = path_template
    import AddonSignals
    signalPayload = {'title': info.get('title'), 'url': info.get('url'), 'download.ID': info.get('download.ID')}
    try:
        AddonSignals.sendSignal('download.started', signalPayload, sourceID='script.module.youtube.dl')
        YoutubeDLWrapper.download(info)
    except YoutubeDLWrapper.youtube_dl.DownloadError, e:
        return DownloadResult(False, e.message, filepath=ytdl._lastDownloadedFilePath)
    except YoutubeDLWrapper.DownloadCanceledException:
        return DownloadResult(False, status='canceled', filepath=ytdl._lastDownloadedFilePath)
    finally:
        ytdl.clearDownloadParams()
        signalPayload['path'] = ytdl._lastDownloadedFilePath
        AddonSignals.sendSignal('download.finished', signalPayload, sourceID='script.module.youtube.dl')

    return DownloadResult(True, filepath=ytdl._lastDownloadedFilePath)


def mightHaveVideo(url, resolve_redirects=False):
    """
    Returns True if the url matches against one of the handled site URLs.
    """
    if resolve_redirects:
        try:
            url = resolve_http_redirect(url)
        except:
            util.ERROR('mightHaveVideo(): Failed to resolve URL')
            return False
Пример #17
0
    def autoPlayPlayback(self):
        currentFile = xbmc.Player().getPlayingFile()

        # Get the active player
        result = self.getNowPlaying()
        if 'result' in result:
            itemtype = result["result"]["item"]["type"]
            addonSettings = xbmcaddon.Addon(id='service.nextup.notification')
            playMode = addonSettings.getSetting("autoPlayMode")
            currentepisodenumber = result["result"]["item"]["episode"]
            currentseasonid = result["result"]["item"]["season"]
            currentshowtitle = result["result"]["item"]["showtitle"].encode(
                'utf-8')
            currentshowtitle = utils.unicodetoascii(currentshowtitle)
            tvshowid = result["result"]["item"]["tvshowid"]
            shortplayMode = addonSettings.getSetting("shortPlayMode")
            shortplayNotification = addonSettings.getSetting(
                "shortPlayNotification")
            shortplayLength = int(
                addonSettings.getSetting("shortPlayLength")) * 60
            showpostplaypreview = addonSettings.getSetting(
                "showPostPlayPreview") == "true"
            showpostplay = addonSettings.getSetting("showPostPlay") == "true"
            shouldshowpostplay = showpostplay and showpostplaypreview

            # Try to get tvshowid by showtitle from kodidb if tvshowid is -1 like in strm streams which are added to kodi db
            if int(tvshowid) == -1:
                tvshowid = self.showtitle_to_id(title=currentshowtitle)
                self.logMsg("Fetched missing tvshowid " + str(tvshowid), 2)

            if (itemtype == "episode"):
                # Get current episodeid
                currentepisodeid = self.get_episode_id(
                    showid=str(tvshowid),
                    showseason=currentseasonid,
                    showepisode=currentepisodenumber)
            else:
                # wtf am i doing here error.. ####
                self.logMsg("Error: cannot determine if episode", 1)
                return

        else:
            # wtf am i doing here error.. ####
            self.logMsg("Error: cannot determine if episode", 1)
            return

        self.currentepisodeid = currentepisodeid
        self.logMsg(
            "Getting details of next up episode for tvshow id: " +
            str(tvshowid), 1)
        if self.currenttvshowid != tvshowid:
            self.currenttvshowid = tvshowid
            self.playedinarow = 1

        result = xbmc.executeJSONRPC(
            '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, '
            '"properties": [ "title", "playcount", "season", "episode", "showtitle", "plot", '
            '"file", "rating", "resume", "tvshowid", "art", "firstaired", "runtime", "writer", '
            '"dateadded", "lastplayed" , "streamdetails"], "sort": {"method": "episode"}}, "id": 1}'
            % tvshowid)

        if result:
            result = unicode(result, 'utf-8', errors='ignore')
            result = json.loads(result)
            self.logMsg("Got details of next up episode %s" % str(result), 2)
            xbmc.sleep(100)

            # Find the next unwatched and the newest added episodes
            if "result" in result and "episodes" in result["result"]:
                includeWatched = addonSettings.getSetting(
                    "includeWatched") == "true"
                episode = self.findNextEpisode(result, currentFile,
                                               includeWatched)

                if episode is None:
                    # no episode get out of here
                    return
                self.logMsg("episode details %s" % str(episode), 2)
                episodeid = episode["episodeid"]

                if includeWatched:
                    includePlaycount = True
                else:
                    includePlaycount = episode["playcount"] == 0
                if includePlaycount and currentepisodeid != episodeid:
                    # we have a next up episode
                    nextUpPage = NextUpInfo(
                        "script-nextup-notification-NextUpInfo.xml",
                        addonSettings.getAddonInfo('path'), "default", "1080i")
                    nextUpPage.setItem(episode)
                    stillWatchingPage = StillWatchingInfo(
                        "script-nextup-notification-StillWatchingInfo.xml",
                        addonSettings.getAddonInfo('path'), "default", "1080i")
                    stillWatchingPage.setItem(episode)
                    playedinarownumber = addonSettings.getSetting(
                        "playedInARow")
                    playTime = xbmc.Player().getTime()
                    totalTime = xbmc.Player().getTotalTime()
                    self.logMsg(
                        "played in a row settings %s" %
                        str(playedinarownumber), 2)
                    self.logMsg("played in a row %s" % str(self.playedinarow),
                                2)

                    if int(self.playedinarow) <= int(playedinarownumber):
                        self.logMsg(
                            "showing next up page as played in a row is %s" %
                            str(self.playedinarow), 2)
                        if (shortplayNotification
                                == "false") and (shortplayLength >=
                                                 totalTime) and (shortplayMode
                                                                 == "true"):
                            self.logMsg("hiding notification for short videos")
                        else:
                            nextUpPage.show()
                    else:
                        self.logMsg(
                            "showing still watching page as played in a row %s"
                            % str(self.playedinarow), 2)
                        if (shortplayNotification
                                == "false") and (shortplayLength >=
                                                 totalTime) and (shortplayMode
                                                                 == "true"):
                            self.logMsg("hiding notification for short videos")
                        else:
                            stillWatchingPage.show()
                    if shouldshowpostplay:
                        self.postPlayPlayback()

                    while xbmc.Player().isPlaying() and (
                            totalTime - playTime >
                            1) and not nextUpPage.isCancel(
                            ) and not nextUpPage.isWatchNow(
                            ) and not stillWatchingPage.isStillWatching(
                            ) and not stillWatchingPage.isCancel():
                        xbmc.sleep(100)
                        try:
                            playTime = xbmc.Player().getTime()
                            totalTime = xbmc.Player().getTotalTime()
                        except:
                            pass
                    if shortplayLength >= totalTime and shortplayMode == "true":
                        #play short video and don't add to playcount
                        self.playedinarow += 0
                        self.logMsg("Continuing short video autoplay - %s")
                        if nextUpPage.isWatchNow(
                        ) or stillWatchingPage.isStillWatching():
                            self.playedinarow = 1
                        shouldPlayDefault = not nextUpPage.isCancel()
                    else:
                        if int(self.playedinarow) <= int(playedinarownumber):
                            nextUpPage.close()
                            shouldPlayDefault = not nextUpPage.isCancel()
                            shouldPlayNonDefault = nextUpPage.isWatchNow()
                        else:
                            stillWatchingPage.close()
                            shouldPlayDefault = stillWatchingPage.isStillWatching(
                            )
                            shouldPlayNonDefault = stillWatchingPage.isStillWatching(
                            )

                        if nextUpPage.isWatchNow(
                        ) or stillWatchingPage.isStillWatching():
                            self.playedinarow = 1
                        else:
                            self.playedinarow += 1

                    if (shouldPlayDefault and not shouldshowpostplay
                            and playMode == "0") or (
                                shouldPlayNonDefault and shouldshowpostplay
                                and playMode == "0") or (shouldPlayNonDefault
                                                         and playMode == "1"):
                        self.logMsg(
                            "playing media episode id %s" % str(episodeid), 2)
                        # Signal to trakt previous episode watched
                        AddonSignals.sendSignal(
                            "NEXTUPWATCHEDSIGNAL",
                            {'episodeid': self.currentepisodeid})

                        # if in postplaypreview mode clear the post play window as its not needed now
                        if shouldshowpostplay:
                            self.postplaywindow = None

                        # Play media
                        xbmc.executeJSONRPC(
                            '{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", '
                            '"params": { "item": {"episodeid": ' +
                            str(episode["episodeid"]) + '} } }')
Пример #18
0
def _send_signal(signal, data):
    AddonSignals.sendSignal(source_id=g.ADDON_ID, signal=signal, data=data)
Пример #19
0
    def autoPlayPlayback(self):
        currentFile = xbmc.Player().getPlayingFile()

        # Get the active player
        result = self.getNowPlaying()
        if 'result' in result:
            itemtype = result["result"]["item"]["type"]
            addonSettings = xbmcaddon.Addon(id='service.nextup.notification')
            playMode = addonSettings.getSetting("autoPlayMode")
            currentepisodenumber = result["result"]["item"]["episode"]
            currentseasonid = result["result"]["item"]["season"]
            currentshowtitle = result["result"]["item"]["showtitle"].encode('utf-8')
            currentshowtitle = utils.unicodetoascii(currentshowtitle)
            tvshowid = result["result"]["item"]["tvshowid"]
            shortplayMode = addonSettings.getSetting("shortPlayMode")
            shortplayNotification= addonSettings.getSetting("shortPlayNotification")
            shortplayLength = int(addonSettings.getSetting("shortPlayLength")) * 60
            showpostplaypreview = addonSettings.getSetting("showPostPlayPreview") == "true"
            showpostplay = addonSettings.getSetting("showPostPlay") == "true"
            shouldshowpostplay = showpostplay and showpostplaypreview

            # Try to get tvshowid by showtitle from kodidb if tvshowid is -1 like in strm streams which are added to kodi db
            if int(tvshowid) == -1:
                tvshowid = self.showtitle_to_id(title=currentshowtitle)
                self.logMsg("Fetched missing tvshowid " + str(tvshowid), 2)

            if (itemtype == "episode"):
                # Get current episodeid
                currentepisodeid = self.get_episode_id(showid=str(tvshowid), showseason=currentseasonid, showepisode=currentepisodenumber)
            else:
                # wtf am i doing here error.. ####
                self.logMsg("Error: cannot determine if episode", 1)
                return

        else:
            # wtf am i doing here error.. ####
            self.logMsg("Error: cannot determine if episode", 1)
            return

        self.currentepisodeid = currentepisodeid
        self.logMsg("Getting details of next up episode for tvshow id: " + str(tvshowid), 1)
        if self.currenttvshowid != tvshowid:
            self.currenttvshowid = tvshowid
            self.playedinarow = 1

        result = xbmc.executeJSONRPC(
            '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, '
            '"properties": [ "title", "playcount", "season", "episode", "showtitle", "plot", '
            '"file", "rating", "resume", "tvshowid", "art", "firstaired", "runtime", "writer", '
            '"dateadded", "lastplayed" , "streamdetails"], "sort": {"method": "episode"}}, "id": 1}'
            % tvshowid)

        if result:
            result = unicode(result, 'utf-8', errors='ignore')
            result = json.loads(result)
            self.logMsg("Got details of next up episode %s" % str(result), 2)
            xbmc.sleep(100)

            # Find the next unwatched and the newest added episodes
            if "result" in result and "episodes" in result["result"]:
                includeWatched = addonSettings.getSetting("includeWatched") == "true"
                episode = self.findNextEpisode(result, currentFile, includeWatched)

                if episode is None:
                    # no episode get out of here
                    return
                self.logMsg("episode details %s" % str(episode), 2)
                episodeid = episode["episodeid"]

                if includeWatched:
                    includePlaycount = True
                else:
                    includePlaycount = episode["playcount"] == 0
                if includePlaycount and currentepisodeid != episodeid:
                    # we have a next up episode
                    nextUpPage = NextUpInfo("script-nextup-notification-NextUpInfo.xml",
                                            addonSettings.getAddonInfo('path'), "default", "1080i")
                    nextUpPage.setItem(episode)
                    stillWatchingPage = StillWatchingInfo(
                        "script-nextup-notification-StillWatchingInfo.xml",
                        addonSettings.getAddonInfo('path'), "default", "1080i")
                    stillWatchingPage.setItem(episode)
                    playedinarownumber = addonSettings.getSetting("playedInARow")
                    playTime = xbmc.Player().getTime()
                    totalTime =  xbmc.Player().getTotalTime()
                    self.logMsg("played in a row settings %s" % str(playedinarownumber), 2)
                    self.logMsg("played in a row %s" % str(self.playedinarow), 2)

                    if int(self.playedinarow) <= int(playedinarownumber):
                        self.logMsg(
                            "showing next up page as played in a row is %s" % str(self.playedinarow), 2)
                        if (shortplayNotification == "false") and (shortplayLength >= totalTime) and (shortplayMode == "true"):
                            self.logMsg("hiding notification for short videos")
                        else:
                            nextUpPage.show()
                    else:
                        self.logMsg(
                            "showing still watching page as played in a row %s" % str(self.playedinarow), 2)
                        if (shortplayNotification == "false") and (shortplayLength >= totalTime) and (shortplayMode == "true"):
                            self.logMsg("hiding notification for short videos")
                        else:
                            stillWatchingPage.show()
                    if shouldshowpostplay:
                        self.postPlayPlayback()

                    while xbmc.Player().isPlaying() and (
                                    totalTime - playTime > 1) and not nextUpPage.isCancel() and not nextUpPage.isWatchNow() and not stillWatchingPage.isStillWatching() and not stillWatchingPage.isCancel():
                        xbmc.sleep(100)
                        try:
                            playTime = xbmc.Player().getTime()
                            totalTime = xbmc.Player().getTotalTime()
                        except:
                            pass
                    if shortplayLength >= totalTime and shortplayMode == "true":
                        #play short video and don't add to playcount
                        self.playedinarow += 0
                        self.logMsg("Continuing short video autoplay - %s")
                        if nextUpPage.isWatchNow() or stillWatchingPage.isStillWatching():
                            self.playedinarow = 1
                        shouldPlayDefault = not nextUpPage.isCancel()
                    else:
                        if int(self.playedinarow) <= int(playedinarownumber):
                            nextUpPage.close()
                            shouldPlayDefault = not nextUpPage.isCancel()
                            shouldPlayNonDefault = nextUpPage.isWatchNow()
                        else:
                            stillWatchingPage.close()
                            shouldPlayDefault = stillWatchingPage.isStillWatching()
                            shouldPlayNonDefault = stillWatchingPage.isStillWatching()

                        if nextUpPage.isWatchNow() or stillWatchingPage.isStillWatching():
                            self.playedinarow = 1
                        else:
                            self.playedinarow += 1


                    if (shouldPlayDefault and not shouldshowpostplay and playMode == "0") or (shouldPlayNonDefault and shouldshowpostplay and playMode == "0") or (shouldPlayNonDefault and playMode == "1"):
                        self.logMsg("playing media episode id %s" % str(episodeid), 2)
                        # Signal to trakt previous episode watched
                        AddonSignals.sendSignal("NEXTUPWATCHEDSIGNAL", {'episodeid': self.currentepisodeid})

                        # if in postplaypreview mode clear the post play window as its not needed now
                        if shouldshowpostplay:
                            self.postplaywindow = None

                        # Play media
                        xbmc.executeJSONRPC(
                            '{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", '
                            '"params": { "item": {"episodeid": ' + str(episode["episodeid"]) + '} } }')
Пример #20
0
    def onPlayBackStarted(self):
        self.helper.log('Getting next episode info')
        next_ep_id = self.helper.r.get_next_episode_id(self.video_id)

        if next_ep_id['next_in_sequence'].get('nid'):
            next_ep_info = self.helper.r.get_episode_info(next_ep_id['next_in_sequence']['nid'])

            next_ep_title = next_ep_info['videos'][0]['episode_name'] if next_ep_info['videos'][0].get('episode_name') else next_ep_info['videos'][0].get('name')

            self.helper.log('Next episode name: ' + next_ep_title.encode('utf-8'))
            self.helper.log('Current episode name: ' + self.current_episode_info['title'].encode('utf-8'))

            current_episode = {}
            current_episode["episodeid"] = self.video_id
            current_episode["tvshowid"] = ''
            current_episode["title"] = self.current_episode_info['title']
            current_episode["art"] = {}
            current_episode["art"]["tvshow.poster"] = ''
            current_episode["art"]["thumb"] = self.current_episode_art['thumb']
            current_episode["art"]["tvshow.fanart"] = self.current_episode_art['fanart']
            current_episode["art"]["tvshow.landscape"] = ''
            current_episode["art"]["tvshow.clearart"] = ''
            current_episode["art"]["tvshow.clearlogo"] = ''
            current_episode["plot"] = self.current_episode_info['title']
            current_episode["showtitle"] = self.current_episode_info['tvshowtitle']
            current_episode["playcount"] = ''
            current_episode["season"] = self.current_episode_info['season']
            current_episode["episode"] = self.current_episode_info['episode']
            current_episode["rating"] = None
            current_episode["firstaired"] = self.current_episode_info['aired']

            next_episode = {}
            next_episode["episodeid"] = next_ep_info['videos'][0]['id']
            next_episode["tvshowid"] = ''
            next_episode["title"] = next_ep_title
            next_episode["art"] = {}
            next_episode["art"]["tvshow.poster"] = ''
            next_episode["art"]["thumb"] = next_ep_info['videos'][0]['media']['images'][0]['1920x1080'] if next_ep_info['videos'][0]['media']['images'][0].get('1920x1080') else None
            next_episode["art"]["tvshow.fanart"] = next_ep_info['videos'][0]['media']['images'][0]['1920x1080'] if next_ep_info['videos'][0]['media']['images'][0].get('1920x1080') else None
            next_episode["art"]["tvshow.landscape"] = ''
            next_episode["art"]["tvshow.clearart"] = ''
            next_episode["art"]["tvshow.clearlogo"] = ''
            next_episode["plot"] = next_ep_info['videos'][0].get('description')
            next_episode["showtitle"] = next_ep_info['videos'][0].get('series')
            next_episode["playcount"] = ''
            next_episode["season"] = next_ep_info['videos'][0].get('season')
            next_episode["episode"] = next_ep_info['videos'][0].get('episode')
            next_episode["rating"] = None
            next_episode["firstaired"] = next_ep_info['videos'][0].get('created')

            if next_ep_info['videos'][0]['premium'] == 1:
                sticker = 'entertainment'
            else:
                sticker = None

            play_info = {}
            play_info['video_id'] = next_ep_info['videos'][0]['id']
            play_info['sticker'] = sticker

            next_info = {
                'current_episode': current_episode,
                'next_episode': next_episode,
                'play_info': play_info,
                'notification_time': ''
            }

            AddonSignals.sendSignal("upnext_data", next_info, source_id=self.helper.addon_name)

        else:
            self.helper.log('No next episode available')
Пример #21
0
def _send_signal(signal, data):
    _data = b64encode(pickle.dumps(data,
                                   pickle.HIGHEST_PROTOCOL)).decode('ascii')
    AddonSignals.sendSignal(source_id=G.ADDON_ID, signal=signal, data=_data)
Пример #22
0
    def autoPlayPlayback(self):
        currentFile = xbmc.Player().getPlayingFile()

        # Get the active player
        result = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "Player.GetActivePlayers"}')
        result = unicode(result, 'utf-8', errors='ignore')
        self.logMsg("Got active player " + result, 2)
        result = json.loads(result)

        # Seems to work too fast loop whilst waiting for it to become active
        while not result["result"]:
            result = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id": 1, "method": "Player.GetActivePlayers"}')
            result = unicode(result, 'utf-8', errors='ignore')
            self.logMsg("Got active player " + result, 2)
            result = json.loads(result)

        if 'result' in result and result["result"][0] is not None:
            playerid = result["result"][0]["playerid"]

            # Get details of the playing media
            self.logMsg("Getting details of playing media", 1)
            result = xbmc.executeJSONRPC(
                '{"jsonrpc": "2.0", "id": 1, "method": "Player.GetItem", "params": {"playerid": ' + str(
                    playerid) + ', "properties": ["showtitle", "tvshowid", "episode", "season", "playcount"] } }')
            result = unicode(result, 'utf-8', errors='ignore')
            self.logMsg("Got details of playing media" + result, 2)

            result = json.loads(result)
            if 'result' in result:
                itemtype = result["result"]["item"]["type"]

            if self.strm_query(result):
                addonSettings = xbmcaddon.Addon(id='service.nextup.notification')
                playMode = addonSettings.getSetting("autoPlayMode")
                currentepisodenumber = result["result"]["item"]["episode"]
                currentseasonid = result["result"]["item"]["season"]
                currentshowtitle = result["result"]["item"]["showtitle"]
                tvshowid = result["result"]["item"]["tvshowid"]
                shortplayMode = addonSettings.getSetting("shortPlayMode")
                shortplayNotification= addonSettings.getSetting("shortPlayNotification")
                shortplayLength = int(addonSettings.getSetting("shortPlayLength")) * 60


                if (itemtype == "episode"):
                    # Get the next up episode
                    currentepisodeid = result["result"]["item"]["id"]
                elif tvshowid == -1:
                    # I am a STRM ###
                    tvshowid, episodeid = self.iStream_fix(tvshowid, currentshowtitle, currentepisodenumber, currentseasonid)
                    currentepisodeid = episodeid
                else:
                    # wtf am i doing here error.. ####
                    self.logMsg("Error: cannot determine if episode", 1)
                    return

            self.currentepisodeid = currentepisodeid
            self.logMsg("Getting details of next up episode for tvshow id: " + str(tvshowid), 1)
            if self.currenttvshowid != tvshowid:
                self.currenttvshowid = tvshowid
                self.playedinarow = 1

            result = xbmc.executeJSONRPC(
                '{"jsonrpc": "2.0", "method": "VideoLibrary.GetEpisodes", "params": {"tvshowid": %d, '
                '"properties": [ "title", "playcount", "season", "episode", "showtitle", "plot", '
                '"file", "rating", "resume", "tvshowid", "art", "firstaired", "runtime", "writer", '
                '"dateadded", "lastplayed" , "streamdetails"], "sort": {"method": "episode"}}, "id": 1}'
                % tvshowid)

            if result:
                result = unicode(result, 'utf-8', errors='ignore')
                result = json.loads(result)
                self.logMsg("Got details of next up episode %s" % str(result), 2)
                xbmc.sleep(100)

                # Find the next unwatched and the newest added episodes
                if "result" in result and "episodes" in result["result"]:
                    includeWatched = addonSettings.getSetting("includeWatched") == "true"
                    episode = self.findNextEpisode(result, currentFile, includeWatched)

                    if episode is None:
                        # no episode get out of here
                        return
                    self.logMsg("episode details %s" % str(episode), 2)
                    episodeid = episode["episodeid"]

                    if includeWatched:
                        includePlaycount = True
                    else:
                        includePlaycount = episode["playcount"] == 0
                    if includePlaycount and currentepisodeid != episodeid:
                        # we have a next up episode
                        nextUpPage = NextUpInfo("script-nextup-notification-NextUpInfo.xml",
                                                addonSettings.getAddonInfo('path'), "default", "1080i")
                        nextUpPage.setItem(episode)
                        stillWatchingPage = StillWatchingInfo(
                            "script-nextup-notification-StillWatchingInfo.xml",
                            addonSettings.getAddonInfo('path'), "default", "1080i")
                        stillWatchingPage.setItem(episode)
                        playedinarownumber = addonSettings.getSetting("playedInARow")
                        playTime = xbmc.Player().getTime()
                        totalTime =  xbmc.Player().getTotalTime()
                        self.logMsg("played in a row settings %s" % str(playedinarownumber), 2)
                        self.logMsg("played in a row %s" % str(self.playedinarow), 2)
                        if int(self.playedinarow) <= int(playedinarownumber):
                            self.logMsg(
                                "showing next up page as played in a row is %s" % str(self.playedinarow), 2)
                            if (shortplayNotification == "false") and (shortplayLength >= totalTime) and (shortplayMode == "true"):
                                self.logMsg("hiding notification for short videos")
                            else:
                                nextUpPage.show()
                        else:
                            self.logMsg(
                                "showing still watching page as played in a row %s" % str(self.playedinarow), 2)
                            if (shortplayNotification == "false") and (shortplayLength >= totalTime) and (shortplayMode == "true"):
                                self.logMsg("hiding notification for short videos")
                            else:
                                stillWatchingPage.show()
                        while xbmc.Player().isPlaying() and (
                                        totalTime - playTime > 1) and not nextUpPage.isCancel() and not nextUpPage.isWatchNow() and not stillWatchingPage.isStillWatching() and not stillWatchingPage.isCancel():
                            xbmc.sleep(100)
                            try:
                                playTime = xbmc.Player().getTime()
                                totalTime = xbmc.Player().getTotalTime()
                            except:
                                pass
                        if shortplayLength >= totalTime and shortplayMode == "true":
                            #play short video and don't add to playcount
                            self.playedinarow += 0
                            self.logMsg("Continuing short video autoplay - %s")
                            if nextUpPage.isWatchNow() or stillWatchingPage.isStillWatching():
                                self.playedinarow = 1
                            shouldPlayDefault = not nextUpPage.isCancel()
                        else:
                            if int(self.playedinarow) <= int(playedinarownumber):
                                nextUpPage.close()
                                shouldPlayDefault = not nextUpPage.isCancel()
                                shouldPlayNonDefault = nextUpPage.isWatchNow()
                            else:
                                stillWatchingPage.close()
                                shouldPlayDefault = stillWatchingPage.isStillWatching()
                                shouldPlayNonDefault = stillWatchingPage.isStillWatching()

                            if nextUpPage.isWatchNow() or stillWatchingPage.isStillWatching():
                                self.playedinarow = 1
                            else:
                                self.playedinarow += 1

                        if (shouldPlayDefault and playMode == "0") or (shouldPlayNonDefault and playMode == "1"):
                            self.logMsg("playing media episode id %s" % str(episodeid), 2)
                            # Signal to trakt previous episode watched
                            AddonSignals.sendSignal("NEXTUPWATCHEDSIGNAL", {'episodeid': self.currentepisodeid})

                            # Play media
                            xbmc.executeJSONRPC(
                                '{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", '
                                '"params": { "item": {"episodeid": ' + str(episode["episodeid"]) + '} } }')
Пример #23
0
def send_signal(signal, data=None):
    """Send a signal via AddonSignals"""
    AddonSignals.sendSignal(source_id=g.ADDON_ID, signal=signal, data=data)
    ytdl.params["quiet"] = True
    ytdl.params["outtmpl"] = path_template
    import AddonSignals

    signalPayload = {"title": info.get("title"), "url": info.get("url"), "download.ID": info.get("download.ID")}
    try:
        AddonSignals.sendSignal("download.started", signalPayload, sourceID="script.module.youtube.dl")
        YoutubeDLWrapper.download(info)
    except YoutubeDLWrapper.youtube_dl.DownloadError, e:
        return DownloadResult(False, e.message, filepath=ytdl._lastDownloadedFilePath)
    except YoutubeDLWrapper.DownloadCanceledException:
        return DownloadResult(False, status="canceled", filepath=ytdl._lastDownloadedFilePath)
    finally:
        ytdl.clearDownloadParams()
        signalPayload["path"] = ytdl._lastDownloadedFilePath
        AddonSignals.sendSignal("download.finished", signalPayload, sourceID="script.module.youtube.dl")

    return DownloadResult(True, filepath=ytdl._lastDownloadedFilePath)


def mightHaveVideo(url, resolve_redirects=False):
    """
    Returns True if the url matches against one of the handled site URLs.
    """
    if resolve_redirects:
        try:
            url = resolve_http_redirect(url)
        except:
            util.ERROR("mightHaveVideo(): Failed to resolve URL")
            return False