Exemplo n.º 1
0
def Scrape_Sites(list_type):
    """
This is just a very rough example showing how simple it is to make use of the NaN Scrapers module.
We send through details of what we want to find and NaN Scrapers will search multiple websites for this content.
    """
    content = ''
    if list_type == 'movie_dialog':
        content = nanscrapers.scrape_movie_with_dialog(title='Trainspotting', year='1996', imdb='tt0117951', host=None, include_disabled=False, timeout=30)
    elif list_type == 'episode_dialog':
        content = nanscrapers.scrape_episode_with_dialog(title='Fraggle Rock', show_year='1983', year='1985', season='3', episode='4', imdb='tt0085017', tvdb=None, host=None, include_disabled=False, timeout=30)
    elif list_type == 'song_dialog':
        content = nanscrapers.scrape_song_with_dialog(title='Fools Gold', artist='Stone Roses', host=None, include_disabled=False, timeout=30)

# If the item returned is a dictionary that's great we know we have a list to work with
    if koding.Data_Type(content) == 'dict':
        xbmc.log(repr(content),2)
        playback = koding.Play_Video(video=content["url"], showbusy=True)
 
# It may be a plugin or direct url has been sent through, if so lets use the list_type variable
    elif not list_type.endswith('_dialog'):
        playback = koding.Play_Video(video=list_type, showbusy=True)

# Nothing useful has been found, lets exit back to the list
    else:
        return

# If the playback returned as True then it was successful but if it was False we know we need to try again for another source
    if not playback:
        if dialog.yesno('PLAYBACK FAILED','The video may have been removed, the web host may have altered their code or this video may not be available in your region. [COLOR=dodgerblue]Would you like to try another source?[/COLOR]'):
            Scrape_Sites(list_type)
Exemplo n.º 2
0
def scrape_movie(name, year, imdb):
    import xbmc
    from nanscrapers import scrape_movie_with_dialog
    link = scrape_movie_with_dialog(name, year, imdb, timeout=600)
    if link is False:
        xbmcgui.Dialog().ok("Movie not found",
                            "No Links Found for " + name + " (" + year + ")")
    else:
        if link:
            url = link['url']
            xbmc.Player().play(url, xbmcgui.ListItem(name))
Exemplo n.º 3
0
    def getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, timeout=30,
                   progress=True, preset="search", dialog=None, exclude=None, scraper_title=False, queueing=False):

        year = str(year)
        content = 'movie' if tvshowtitle == None else 'episode'
        allow_debrid = control.setting('allow_debrid') == "true"

        if content == 'movie':
            title = cleantitle.normalize(title)
            links_scraper = nanscrapers.scrape_movie(title, year, imdb, timeout=timeout, exclude=exclude,
                                                     enable_debrid=allow_debrid)
        elif content == 'episode':
            if scraper_title:
                tvshowtitle = title
            tvshowtitle = cleantitle.normalize(tvshowtitle)
            links_scraper = nanscrapers.scrape_episode(tvshowtitle, year, premiered, season, episode, imdb, tvdb,
                                                       timeout=timeout, exclude=exclude, enable_debrid=allow_debrid)
        else:
            return

        if not queueing and control.setting('use_link_dialog') == 'true':
            if control.setting('check_url') == "true":
                check_url = True
            else:
                check_url = False
            if content == 'movie':
                link, items = nanscrapers.scrape_movie_with_dialog(title, year, imdb, timeout=timeout, exclude=exclude,
                                                                   sort_function=sources.sort_function,
                                                                   check_url=check_url, extended=True,
                                                                   enable_debrid=allow_debrid)
            elif content == "episode":
                link, items = nanscrapers.scrape_episode_with_dialog(tvshowtitle, year, premiered, season, episode,
                                                                     imdb, tvdb,
                                                                     timeout=timeout, exclude=exclude,
                                                                     sort_function=sources.sort_function,
                                                                     check_url=check_url, extended=True,
                                                                     enable_debrid=allow_debrid)
            else:
                return

            if link is None:
                return False

            if type(link) == dict and "path" in link:
                link = link["path"]
            url = link['url']
            if allow_debrid:
                new_url = debrid.resolve(url)
                if new_url:
                    url = new_url
            import urlresolver9
            try:
                hmf = urlresolver9.HostedMediaFile(url=url, include_disabled=False,
                                                   include_universal=allow_debrid)
                if hmf.valid_url() == True:
                    resolved_url = hmf.resolve()
                else:
                    resolved_url = url
            except:
                resolved_url = None

            if resolved_url and sources().check_playable(resolved_url) is not None:
                url = resolved_url
            else:
                if control.setting('link_fallthtough') == 'true':
                    try:
                        links = []
                        for item in items:
                            if type(item) == dict and "path" in item:
                                links.extend(item["path"][1])
                            else:
                                links.extend(item[1])
                        index = links.index(link)
                        links = links[index + 1:]
                        for link in links:
                            try:
                                hmf = urlresolver9.HostedMediaFile(url=link["url"], include_disabled=False,
                                                                   include_universal=allow_debrid)
                                if hmf.valid_url() == True:
                                    resolved_url = hmf.resolve()
                                else:
                                    resolved_url = None
                            except:
                                resolved_url = None

                            if resolved_url and sources().check_playable(resolved_url) is not None:
                                url = resolved_url
                                return url
                        url = None
                    except:
                        pass
                else:
                    url = None
            return url

        sd_links = []
        non_direct = []
        sd_non_direct = []
        links_scraper = links_scraper()
        for scraper_links in links_scraper:
            if scraper_links is not None:
                random.shuffle(scraper_links)
                for scraper_link in scraper_links:
                    if dialog is not None and dialog.iscanceled():
                        return

                    if allow_debrid:
                        new_url = debrid.resolve(scraper_link['url'])
                        if new_url:
                            scraper_link['url'] = new_url

                    if (not control.setting('allow_openload') == 'true' and 'openload' in scraper_link['url']) or (
                                not control.setting('allow_the_video_me') == 'true' and 'thevideo.me' in scraper_link[
                                'url']):
                        continue
                    if preset.lower() == 'searchsd':
                        try:
                            quality = int(scraper_link['quality'])
                            if quality > 576:
                                continue
                        except:
                            if scraper_link['quality'] not in ["SD", "CAM", "SCR"]:
                                continue
                    elif preset.lower() == 'search':
                        try:
                            quality = int(scraper_link['quality'])
                            if quality <= 576:
                                if scraper_link["direct"]:
                                    sd_links.append(scraper_link)
                                else:
                                    sd_non_direct.append(scraper_link)
                                continue
                        except:
                            if scraper_link['quality'] in ["SD", "CAM", "SCR"]:
                                if scraper_link["direct"]:
                                    sd_links.append(scraper_link)
                                else:
                                    sd_non_direct.append(scraper_link)
                                continue

                    if "m4u" in scraper_link['url']:
                        if sources().check_playable(scraper_link['url']) is not None:
                            return scraper_link['url']

                    else:
                        try:
                            if scraper_link['direct']:
                                import urlresolver9
                                hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                                   include_universal=allow_debrid)
                                if hmf.valid_url() == True: resolved_url = hmf.resolve()
                                # resolved_url = urlresolver9.resolve(scraper_link['url'])
                                if resolved_url and sources().check_playable(resolved_url) is not None:
                                    url = resolved_url
                                    return url
                                else:
                                    if sources().check_playable(scraper_link['url']):
                                        return scraper_link['url']
                            else:
                                non_direct.append(scraper_link)
                        except:
                            if scraper_link['direct']:
                                url = scraper_link['url']
                                if sources().check_playable(url) is not None:
                                    return url
                            else:
                                non_direct.append(scraper_link)

        for scraper_link in non_direct:
            if dialog is not None and dialog.iscanceled():
                return

            if (not control.setting('allow_openload') == 'true' and 'openload' in scraper_link['url']) or (
                        not control.setting('allow_the_video_me') == 'true' and 'thevideo.me' in scraper_link[
                        'url']):
                continue
            if preset.lower() == 'searchsd':
                try:
                    quality = int(scraper_link['quality'])
                    if quality > 576:
                        continue
                except:
                    if scraper_link['quality'] not in ["SD", "CAM", "SCR"]:
                        continue
            elif preset.lower() == 'search':
                try:
                    quality = int(scraper_link['quality'])
                    if quality <= 576:
                        sd_non_direct.append(scraper_link)
                        continue
                except:
                    if scraper_link['quality'] in ["SD", "CAM", "SCR"]:
                        sd_non_direct.append(scraper_link)
                        continue

            try:
                hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                   include_universal=allow_debrid)
                if hmf.valid_url() == True: resolved_url = hmf.resolve()
                # resolved_url = urlresolver9.resolve(scraper_link['url'])
            except:
                continue
            if resolved_url and (
                        resolved_url.startswith("plugin://") or sources().check_playable(resolved_url) is not None):
                url = resolved_url
                return url

        for scraper_link in sd_links:

            if dialog is not None and dialog.iscanceled():
                return

            if "m4u" in scraper_link['url']:
                return scraper_link['url']

            else:
                try:
                    if scraper_link['direct']:
                        import urlresolver9
                        hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                           include_universal=allow_debrid)
                        if hmf.valid_url() == True: resolved_url = hmf.resolve()
                        # resolved_url = urlresolver9.resolve(scraper_link['url'])
                        if resolved_url and sources().check_playable(resolved_url) is not None:
                            url = resolved_url
                            return url
                        else:
                            if sources().check_playable(scraper_link['url']):
                                return scraper_link['url']
                    else:
                        non_direct.append(scraper_link)
                except:
                    if scraper_link['direct']:
                        url = scraper_link['url']
                        if sources().check_playable(url) is not None:
                            return url
                    else:
                        non_direct.append(scraper_link)

        try:
            import urlresolver9
        except:
            control.dialog.ok("Dependency missing",
                              "please install script.mrknow.urlresolver to resolve non-direct links")
            return

        for scraper_link in sd_non_direct:
            if dialog is not None and dialog.iscanceled():
                return

            try:
                hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                   include_universal=allow_debrid)
                if hmf.valid_url() == True: resolved_url = hmf.resolve()
                # resolved_url = urlresolver9.resolve(scraper_link['url'])
            except:
                continue
            if resolved_url and (
                        resolved_url.startswith("plugin://") or sources().check_playable(resolved_url) is not None):
                url = resolved_url
                return url
Exemplo n.º 4
0
    def getSources(title,
                   year,
                   imdb,
                   tvdb,
                   season,
                   episode,
                   tvshowtitle,
                   premiered,
                   timeout=30,
                   progress=True,
                   preset="search",
                   dialog=None,
                   exclude=None,
                   scraper_title=False):

        year = str(year)

        content = 'movie' if tvshowtitle == None else 'episode'

        if content == 'movie':
            title = cleantitle.normalize(title)
            links_scraper = nanscrapers.scrape_movie(title,
                                                     year,
                                                     imdb,
                                                     timeout=timeout,
                                                     exclude=exclude)
        elif content == 'episode':
            if scraper_title:
                tvshowtitle = title
            tvshowtitle = cleantitle.normalize(tvshowtitle)
            links_scraper = nanscrapers.scrape_episode(tvshowtitle,
                                                       year,
                                                       premiered,
                                                       season,
                                                       episode,
                                                       imdb,
                                                       tvdb,
                                                       timeout=timeout,
                                                       exclude=exclude)
        else:
            return

        allow_debrid = bool(control.setting('allow_debrid'))

        if control.setting('use_link_dialog') == 'true':
            if content == 'movie':
                link = nanscrapers.scrape_movie_with_dialog(
                    title,
                    year,
                    imdb,
                    timeout=timeout,
                    exclude=exclude,
                    sort_function=sources.sort_function)
            elif content == "episode":
                link = nanscrapers.scrape_episode_with_dialog(
                    tvshowtitle,
                    year,
                    premiered,
                    season,
                    episode,
                    imdb,
                    tvdb,
                    timeout=timeout,
                    exclude=exclude,
                    sort_function=sources.sort_function)
            else:
                return

            url = link['url']
            import urlresolver9
            hmf = urlresolver9.HostedMediaFile(url=url,
                                               include_disabled=False,
                                               include_universal=allow_debrid)
            if hmf.valid_url() == True:
                resolved_url = hmf.resolve()
            else:
                resolved_url = None
            if resolved_url and sources().check_playable(
                    resolved_url) is not None:
                url = resolved_url
            return url

        sd_links = []
        non_direct = []
        sd_non_direct = []
        links_scraper = links_scraper()
        for scraper_links in links_scraper:
            if scraper_links is not None:
                random.shuffle(scraper_links)
                for scraper_link in scraper_links:
                    if dialog is not None and dialog.iscanceled():
                        return

                    if (not control.setting('allow_openload') == 'true'
                            and 'openload' in scraper_link['url']
                        ) or (
                            not control.setting('allow_the_video_me') == 'true'
                            and 'thevideo.me' in scraper_link['url']):
                        continue
                    if preset.lower() == 'searchsd':
                        try:
                            quality = int(scraper_link['quality'])
                            if quality > 576:
                                continue
                        except:
                            if scraper_link['quality'] not in [
                                    "SD", "CAM", "SCR"
                            ]:
                                continue
                    elif preset.lower() == 'search':
                        try:
                            quality = int(scraper_link['quality'])
                            if quality <= 576:
                                sd_links.append(scraper_link)
                                continue
                        except:
                            if scraper_link['quality'] in ["SD", "CAM", "SCR"]:
                                sd_links.append(scraper_link)
                                continue

                    if "m4u" in scraper_link['url']:
                        if sources().check_playable(
                                scraper_link['url']) is not None:
                            return scraper_link['url']

                    else:
                        try:
                            if scraper_link['direct']:
                                import urlresolver9
                                hmf = urlresolver9.HostedMediaFile(
                                    url=scraper_link['url'],
                                    include_disabled=False,
                                    include_universal=allow_debrid)
                                if hmf.valid_url() == True:
                                    resolved_url = hmf.resolve()
                                # resolved_url = urlresolver9.resolve(scraper_link['url'])
                                if resolved_url and sources().check_playable(
                                        resolved_url) is not None:
                                    url = resolved_url
                                    return url
                                else:
                                    if sources().check_playable(
                                            scraper_link['url']):
                                        return scraper_link['url']
                            else:
                                non_direct.append(scraper_link)
                        except:
                            if scraper_link['direct']:
                                url = scraper_link['url']
                                if sources().check_playable(url) is not None:
                                    return url
                            else:
                                non_direct.append(scraper_link)

        for scraper_link in non_direct:
            if dialog is not None and dialog.iscanceled():
                return

            if (not control.setting('allow_openload') == 'true'
                    and 'openload' in scraper_link['url']) or (
                        not control.setting('allow_the_video_me') == 'true'
                        and 'thevideo.me' in scraper_link['url']):
                continue
            if preset.lower() == 'searchsd':
                try:
                    quality = int(scraper_link['quality'])
                    if quality > 576:
                        continue
                except:
                    if scraper_link['quality'] not in ["SD", "CAM", "SCR"]:
                        continue
            elif preset.lower() == 'search':
                try:
                    quality = int(scraper_link['quality'])
                    if quality <= 576:
                        sd_non_direct.append(scraper_link)
                        continue
                except:
                    if scraper_link['quality'] in ["SD", "CAM", "SCR"]:
                        sd_non_direct.append(scraper_link)
                        continue

            try:
                hmf = urlresolver9.HostedMediaFile(
                    url=scraper_link['url'],
                    include_disabled=False,
                    include_universal=allow_debrid)
                if hmf.valid_url() == True: resolved_url = hmf.resolve()
                # resolved_url = urlresolver9.resolve(scraper_link['url'])
            except:
                continue
            if resolved_url and (resolved_url.startswith("plugin://")
                                 or sources().check_playable(resolved_url)
                                 is not None):
                url = resolved_url
                return url

        for scraper_link in sd_links:

            if dialog is not None and dialog.iscanceled():
                return

            if "m4u" in scraper_link['url']:
                return scraper_link['url']

            else:
                try:
                    if scraper_link['direct']:
                        import urlresolver9
                        hmf = urlresolver9.HostedMediaFile(
                            url=scraper_link['url'],
                            include_disabled=False,
                            include_universal=allow_debrid)
                        if hmf.valid_url() == True:
                            resolved_url = hmf.resolve()
                        # resolved_url = urlresolver9.resolve(scraper_link['url'])
                        if resolved_url and sources().check_playable(
                                resolved_url) is not None:
                            url = resolved_url
                            return url
                        else:
                            if sources().check_playable(scraper_link['url']):
                                return scraper_link['url']
                    else:
                        non_direct.append(scraper_link)
                except:
                    if scraper_link['direct']:
                        url = scraper_link['url']
                        if sources().check_playable(url) is not None:
                            return url
                    else:
                        non_direct.append(scraper_link)

        try:
            import urlresolver9
        except:
            control.dialog.ok(
                "Dependency missing",
                "please install script.mrknow.urlresolver to resolve non-direct links"
            )
            return

        for scraper_link in sd_non_direct:
            if dialog is not None and dialog.iscanceled():
                return

            try:
                hmf = urlresolver9.HostedMediaFile(
                    url=scraper_link['url'],
                    include_disabled=False,
                    include_universal=allow_debrid)
                if hmf.valid_url() == True: resolved_url = hmf.resolve()
                # resolved_url = urlresolver9.resolve(scraper_link['url'])
            except:
                continue
            if resolved_url and (resolved_url.startswith("plugin://")
                                 or sources().check_playable(resolved_url)
                                 is not None):
                url = resolved_url
                return url
Exemplo n.º 5
0
    def getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, timeout=30,
                   progress=True, preset="search", dialog=None, exclude=None, scraper_title=False):

        year = str(year)

        content = 'movie' if tvshowtitle == None else 'episode'

        if content == 'movie':
            title = cleantitle.normalize(title)
            links_scraper = nanscrapers.scrape_movie(title, year, imdb, timeout=timeout, exclude=exclude)
        elif content == 'episode':
            if scraper_title:
                tvshowtitle = title
            tvshowtitle = cleantitle.normalize(tvshowtitle)
            links_scraper = nanscrapers.scrape_episode(tvshowtitle, year, premiered, season, episode, imdb, tvdb,
                                                       timeout=timeout, exclude=exclude)
        else:
            return

        allow_debrid = bool(control.setting('allow_debrid'))

        if control.setting('use_link_dialog') == 'true':
            if content == 'movie':
                link = nanscrapers.scrape_movie_with_dialog(title, year, imdb, timeout=timeout, exclude=exclude, sort_function=sources.sort_function)
            elif content == "episode":
                link = nanscrapers.scrape_episode_with_dialog(tvshowtitle, year, premiered, season, episode, imdb, tvdb,
                                                       timeout=timeout, exclude=exclude, sort_function=sources.sort_function)
            else:
                return

            url = link['url']
            import urlresolver9
            hmf = urlresolver9.HostedMediaFile(url=url, include_disabled=False,
                                               include_universal=allow_debrid)
            if hmf.valid_url() == True:
                resolved_url = hmf.resolve()
            else:
                resolved_url = None
            if resolved_url and sources().check_playable(resolved_url) is not None:
                url = resolved_url
            return url




        sd_links = []
        non_direct = []
        sd_non_direct = []
        links_scraper = links_scraper()
        for scraper_links in links_scraper:
            if scraper_links is not None:
                random.shuffle(scraper_links)
                for scraper_link in scraper_links:
                    if dialog is not None and dialog.iscanceled():
                        return

                    if (not control.setting('allow_openload') == 'true' and 'openload' in scraper_link['url']) or (
                                not control.setting('allow_the_video_me') == 'true' and 'thevideo.me' in scraper_link[
                                'url']):
                        continue
                    if preset.lower() == 'searchsd':
                        try:
                            quality = int(scraper_link['quality'])
                            if quality > 576:
                                continue
                        except:
                            if scraper_link['quality'] not in ["SD", "CAM", "SCR"]:
                                continue
                    elif preset.lower() == 'search':
                        try:
                            quality = int(scraper_link['quality'])
                            if quality <= 576:
                                sd_links.append(scraper_link)
                                continue
                        except:
                            if scraper_link['quality'] in ["SD", "CAM", "SCR"]:
                                sd_links.append(scraper_link)
                                continue

                    if "m4u" in scraper_link['url']:
                        if sources().check_playable(scraper_link['url']) is not None:
                            return scraper_link['url']

                    else:
                        try:
                            if scraper_link['direct']:
                                import urlresolver9
                                hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                                   include_universal=allow_debrid)
                                if hmf.valid_url() == True: resolved_url = hmf.resolve()
                                # resolved_url = urlresolver9.resolve(scraper_link['url'])
                                if resolved_url and sources().check_playable(resolved_url) is not None:
                                    url = resolved_url
                                    return url
                                else:
                                    if sources().check_playable(scraper_link['url']):
                                        return scraper_link['url']
                            else:
                                non_direct.append(scraper_link)
                        except:
                            if scraper_link['direct']:
                                url = scraper_link['url']
                                if sources().check_playable(url) is not None:
                                    return url
                            else:
                                non_direct.append(scraper_link)

        for scraper_link in non_direct:
            if dialog is not None and dialog.iscanceled():
                return

            if (not control.setting('allow_openload') == 'true' and 'openload' in scraper_link['url']) or (
                        not control.setting('allow_the_video_me') == 'true' and 'thevideo.me' in scraper_link[
                        'url']):
                continue
            if preset.lower() == 'searchsd':
                try:
                    quality = int(scraper_link['quality'])
                    if quality > 576:
                        continue
                except:
                    if scraper_link['quality'] not in ["SD", "CAM", "SCR"]:
                        continue
            elif preset.lower() == 'search':
                try:
                    quality = int(scraper_link['quality'])
                    if quality <= 576:
                        sd_non_direct.append(scraper_link)
                        continue
                except:
                    if scraper_link['quality'] in ["SD", "CAM", "SCR"]:
                        sd_non_direct.append(scraper_link)
                        continue

            try:
                hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                   include_universal=allow_debrid)
                if hmf.valid_url() == True: resolved_url = hmf.resolve()
                # resolved_url = urlresolver9.resolve(scraper_link['url'])
            except:
                continue
            if resolved_url and (
                        resolved_url.startswith("plugin://") or sources().check_playable(resolved_url) is not None):
                url = resolved_url
                return url

        for scraper_link in sd_links:

            if dialog is not None and dialog.iscanceled():
                return

            if "m4u" in scraper_link['url']:
                return scraper_link['url']

            else:
                try:
                    if scraper_link['direct']:
                        import urlresolver9
                        hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                           include_universal=allow_debrid)
                        if hmf.valid_url() == True: resolved_url = hmf.resolve()
                        # resolved_url = urlresolver9.resolve(scraper_link['url'])
                        if resolved_url and sources().check_playable(resolved_url) is not None:
                            url = resolved_url
                            return url
                        else:
                            if sources().check_playable(scraper_link['url']):
                                return scraper_link['url']
                    else:
                        non_direct.append(scraper_link)
                except:
                    if scraper_link['direct']:
                        url = scraper_link['url']
                        if sources().check_playable(url) is not None:
                            return url
                    else:
                        non_direct.append(scraper_link)

        try:
            import urlresolver9
        except:
            control.dialog.ok("Dependency missing",
                              "please install script.mrknow.urlresolver to resolve non-direct links")
            return

        for scraper_link in sd_non_direct:
            if dialog is not None and dialog.iscanceled():
                return

            try:
                hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                   include_universal=allow_debrid)
                if hmf.valid_url() == True: resolved_url = hmf.resolve()
                # resolved_url = urlresolver9.resolve(scraper_link['url'])
            except:
                continue
            if resolved_url and (
                        resolved_url.startswith("plugin://") or sources().check_playable(resolved_url) is not None):
                url = resolved_url
                return url
Exemplo n.º 6
0
    def getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, timeout=20,
                   progress=True, preset="search", dialog=None, exclude=None, scraper_title=False, queueing=False):
        year = str(year)
        content = 'movie' if tvshowtitle == None else 'episode'
        allow_debrid = control.setting('allow_debrid') == "true"

        if not queueing and control.setting('use_link_dialog') == 'true':
            if control.setting('check_url') == "true":
                check_url = True
            else:
                check_url = False
            if content == 'movie':
                link, items = nanscrapers.scrape_movie_with_dialog(title, year, imdb, timeout=timeout, exclude=exclude,
                                                                   sort_function=sources.sort_function,
                                                                   check_url=check_url, extended=True,
                                                                   enable_debrid=allow_debrid)
            elif content == "episode":
                link, items = nanscrapers.scrape_episode_with_dialog(tvshowtitle, year, premiered, season, episode,
                                                                     imdb, tvdb,
                                                                     timeout=timeout, exclude=exclude,
                                                                     sort_function=sources.sort_function,
                                                                     check_url=check_url, extended=True,
                                                                     enable_debrid=allow_debrid)
            else:
                return

            if link is None:
                return False

            if type(link) == dict and "path" in link:
                link = link["path"]
            url = link['url']
            if allow_debrid:
                new_url = debrid.resolve(url)
                if new_url:
                    url = new_url
            import urlresolver9
            try:
                hmf = urlresolver9.HostedMediaFile(url=url, include_disabled=False,
                                                   include_universal=allow_debrid)
                if hmf.valid_url() == True:
                    resolved_url = hmf.resolve()
                else:
                    resolved_url = url
            except:
                resolved_url = None

            if resolved_url and sources().check_playable(resolved_url) is not None:
                url = resolved_url
            else:
                if control.setting('link_fallthtough') == 'true':
                    try:
                        links = []
                        for item in items:
                            if type(item) == dict and "path" in item:
                                links.extend(item["path"][1])
                            else:
                                links.extend(item[1])
                        index = links.index(link)
                        links = links[index + 1:]
                        for link in links:
                            try:
                                hmf = urlresolver9.HostedMediaFile(url=link["url"], include_disabled=False,
                                                                   include_universal=allow_debrid)
                                if hmf.valid_url() == True:
                                    resolved_url = hmf.resolve()
                                else:
                                    resolved_url = None
                            except:
                                resolved_url = None

                            if resolved_url and sources().check_playable(resolved_url) is not None:
                                url = resolved_url
                                return url
                        url = None
                    except:
                        pass
                else:
                    url = None
            return url

        sd_links = []
        non_direct = []
        sd_non_direct = []
        links_scraper = links_scraper()
        for scraper_links in links_scraper:
            if scraper_links is not None:
                random.shuffle(scraper_links)
                for scraper_link in scraper_links:
                    if dialog is not None and dialog.iscanceled():
                        return

                    if allow_debrid:
                        new_url = debrid.resolve(scraper_link['url'])
                        if new_url:
                            scraper_link['url'] = new_url

                    if (not control.setting('allow_openload') == 'true' and 'openload' in scraper_link['url']) or (
                                not control.setting('allow_the_video_me') == 'true' and 'thevideo.me' in scraper_link[
                                'url']):
                        continue
                    if preset.lower() == 'searchsd':
                        try:
                            quality = int(scraper_link['quality'])
                            if quality > 576:
                                continue
                        except:
                            if scraper_link['quality'] not in ["SD", "CAM", "SCR"]:
                                continue
                    elif preset.lower() == 'search':
                        try:
                            quality = int(scraper_link['quality'])
                            if quality <= 576:
                                if scraper_link["direct"]:
                                    sd_links.append(scraper_link)
                                else:
                                    sd_non_direct.append(scraper_link)
                                continue
                        except:
                            if scraper_link['quality'] in ["SD", "CAM", "SCR"]:
                                if scraper_link["direct"]:
                                    sd_links.append(scraper_link)
                                else:
                                    sd_non_direct.append(scraper_link)
                                continue

                    if "m4u" in scraper_link['url']:
                        if sources().check_playable(scraper_link['url']) is not None:
                            return scraper_link['url']

                    else:
                        try:
                            if scraper_link['direct']:
                                import urlresolver9
                                hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                                   include_universal=allow_debrid)
                                if hmf.valid_url() == True: resolved_url = hmf.resolve()
                                # resolved_url = urlresolver9.resolve(scraper_link['url'])
                                if resolved_url and sources().check_playable(resolved_url) is not None:
                                    url = resolved_url
                                    return url
                                else:
                                    if sources().check_playable(scraper_link['url']):
                                        return scraper_link['url']
                            else:
                                non_direct.append(scraper_link)
                        except:#uruGVTeriF
                            if scraper_link['direct']:
                                url = scraper_link['url']
                                if sources().check_playable(url) is not None:
                                    return url
                            else:
                                non_direct.append(scraper_link)

        for scraper_link in non_direct:
            if dialog is not None and dialog.iscanceled():
                return

            if (not control.setting('allow_openload') == 'true' and 'openload' in scraper_link['url']) or (
                        not control.setting('allow_the_video_me') == 'true' and 'thevideo.me' in scraper_link[
                        'url']):
                continue
            if preset.lower() == 'searchsd':
                try:
                    quality = int(scraper_link['quality'])
                    if quality > 576:
                        continue
                except:
                    if scraper_link['quality'] not in ["SD", "CAM", "SCR"]:
                        continue
            elif preset.lower() == 'search':
                try:
                    quality = int(scraper_link['quality'])
                    if quality <= 576:
                        sd_non_direct.append(scraper_link)
                        continue
                except:
                    if scraper_link['quality'] in ["SD", "CAM", "SCR"]:
                        sd_non_direct.append(scraper_link)
                        continue

            try:
                hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                   include_universal=allow_debrid)
                if hmf.valid_url() == True: resolved_url = hmf.resolve()
            except:
                continue
            if resolved_url and (
                        resolved_url.startswith("plugin://") or sources().check_playable(resolved_url) is not None):
                url = resolved_url
                return url

        for scraper_link in sd_links:

            if dialog is not None and dialog.iscanceled():
                return
                                                             #########################
                                                             # əɹəɥ sɐʍ nɹnb ʌʇ əɹıɟ #
                                                             #                       #
                                                             #    ɹəɥdʎɔ noʎ ʞɔnɟ    #
                                                             #########################
            if "m4u" in scraper_link['url']:
                return scraper_link['url']

            else:
                try:
                    if scraper_link['direct']:
                        import urlresolver9
                        hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                           include_universal=allow_debrid)
                        if hmf.valid_url() == True: resolved_url = hmf.resolve()

                        if resolved_url and sources().check_playable(resolved_url) is not None:
                            url = resolved_url
                            return url
                        else:
                            if sources().check_playable(scraper_link['url']):
                                return scraper_link['url']
                    else:
                        non_direct.append(scraper_link)
                except:
                    if scraper_link['direct']:
                        url = scraper_link['url']
                        if sources().check_playable(url) is not None:
                            return url
                    else:
                        non_direct.append(scraper_link)

        try:
            import urlresolver9
        except:
            control.dialog.ok("Dependency missing",
                              "please install script.mrknow.urlresolver to resolve non-direct links")
            return

        for scraper_link in sd_non_direct:
            if dialog is not None and dialog.iscanceled():
                return

            try:
                hmf = urlresolver9.HostedMediaFile(url=scraper_link['url'], include_disabled=False,
                                                   include_universal=allow_debrid)
                if hmf.valid_url() == True: resolved_url = hmf.resolve()
            except:
                continue
            if resolved_url and (
                        resolved_url.startswith("plugin://") or sources().check_playable(resolved_url) is not None):
                url = resolved_url
                return url
Exemplo n.º 7
0
    if name is not "" and year is not "":

        def sort_function(item):
            quality = item[1][0]["quality"]
            if quality == "1080": quality = "HDa"
            if quality == "720": quality = "HDb"
            if quality == "560": quality = "HDc"
            if quality == "HD": quality = "HDd"
            if quality == "480": quality = "SDa"
            if quality == "360": quality = "SDb"
            if quality == "SD": quality = "SDc"

            return quality

        link = nanscrapers.scrape_movie_with_dialog(
            name, year, imdb, timeout=600, sort_function=sort_function)
        if link is False:
            xbmcgui.Dialog().ok(
                "Movie not found",
                "No Links Found for " + name + " (" + year + ")")
        else:
            if link:
                url = link['url']
                try:
                    xbmc.log("resolving " + url)
                    resolved_url = urlresolver.resolve(url)
                    xbmc.log("resolved")
                except:
                    xbmcgui.Dialog().notification("Scraper test",
                                                  "unplayable stream")
                    sys.exit()