def getMusicSources(title, artist, timeout=30, progress=True, preset="search", dialog=None, exclude=None, queueing=False): title = cleantitle.normalize(title) links_scraper = nanscrapers.scrape_song(title, artist, timeout=timeout, exclude=exclude) sd_links = [] non_direct = [] sd_non_direct = [] allow_debrid = bool(control.setting('allow_debrid')) 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': if scraper_link['quality'] not in ["SD"]: continue elif preset.lower() == 'search': if scraper_link['quality'] in ["SD"]: sd_links.append(scraper_link) continue 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 sd_links: if dialog is not None and dialog.iscanceled(): return 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 non_direct: if dialog is not None and dialog.iscanceled(): return if preset.lower() == 'searchsd': if scraper_link['quality'] not in ["SD"]: continue elif preset.lower() == 'search': if scraper_link['quality'] in ["SD"]: 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_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
def get_music_sources(title, artist, timeout=30, preset="search", dialog=None, exclude=None, listitem=None, output_function=koding.Play_Video, skip_selector=False, player=None): """ scrapes for music sources using NaN scraper library Args: title: song title artist: song artist timeout: timeout for scraping link preset: preferred quality of stream dialog: dialog to use for displaying messages exclude: list of scrapers to exclude Returns: Boolean indicating playback success """ title = title allow_debrid = ADDON.getSetting('allow_debrid') == "true" if ADDON.getSetting( 'use_link_dialog') == 'Link Selector' and not skip_selector: link, rest = nanscrapers.scrape_song_with_dialog( title, artist, timeout=timeout, exclude=exclude, enable_debrid=allow_debrid, extended=True) if type(link) == dict and "path" in link: link = link["path"] if link is None: return False url = link['url'] if ADDON.getSetting('link_fallthrough') == 'true': played = False index = 0 links = [] for item in rest: 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:] num_results = len(rest) + 1 while not played: try: if dialog is not None and dialog.iscanceled(): return if dialog is not None: index = index + 1 percent = int((index * 100) / num_results) line = "%s - %s (%s)" % (link['scraper'], link['source'], link['quality']) dialog.update(percent, line) except: pass try: played = output_function(url, showbusy=False, ignore_dp=True, item=listitem, player=player) link = links[0] links = links[1:] except: return False return played else: return output_function(url, showbusy=False, ignore_dp=True, item=listitem, player=player) links_scraper = nanscrapers.scrape_song(title, artist, timeout=timeout, exclude=exclude, enable_debrid=allow_debrid) sd_links = [] num_scrapers = len(nanscrapers.relevant_scrapers()) index = 0 try: for scraper_links in links_scraper(): if dialog is not None and dialog.iscanceled(): return if dialog is not None: index = index + 1 percent = int((index * 100) / num_scrapers) dialog.update(percent) 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 Sources().__check_skip_pairing(scraper_link): continue quality = Sources.__determine_quality( scraper_link["quality"]) preset = preset.lower() if preset == 'searchsd': if quality == "HD": continue elif preset == "search": if quality == "SD": sd_links.append(scraper_link) result = output_function(scraper_link["url"], showbusy=False, ignore_dp=True, item=listitem, player=player) if result: return result for scraper_link in sd_links: if dialog is not None and dialog.iscanceled(): return result = output_function(scraper_link["url"], showbusy=False, ignore_dp=True, item=listitem, player=player) if result: return result except: pass return False
def get_music_sources(title, artist, timeout=30, preset="search", dialog=None, exclude=None, listitem=None, output_function=koding.Play_Video): """ scrapes for music sources using NaN scraper library Args: title: song title artist: song artist timeout: timeout for scraping link preset: preferred quality of stream dialog: dialog to use for displaying messages exclude: list of scrapers to exclude Returns: Boolean indicating playback success """ title = title allow_debrid = ADDON.getSetting('allow_debrid') == "true" links_scraper = nanscrapers.scrape_song(title, artist, timeout=timeout, exclude=exclude, enable_debrid=allow_debrid) sd_links = [] num_scrapers = len(nanscrapers.relevant_scrapers()) index = 0 for scraper_links in links_scraper(): if dialog is not None and dialog.iscanceled(): return if dialog is not None: index = index + 1 percent = int((index * 100) / num_scrapers) dialog.update(percent) 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 Sources().__check_skip_pairing(scraper_link): continue quality = Sources.__determine_quality( scraper_link["quality"]) preset = preset.lower() if preset == 'searchsd': if quality == "HD": continue elif preset == "search": if quality == "SD": sd_links.append(scraper_link) result = output_function(scraper_link["url"], showbusy=False, ignore_dp=True, item=listitem) if result: return result for scraper_link in sd_links: if dialog is not None and dialog.iscanceled(): return result = output_function(scraper_link["url"], showbusy=False, ignore_dp=True, item=listitem) if result: return result return False
def get_music_sources(title, artist, timeout=30, preset="search", dialog=None, exclude=None, listitem=None, output_function=koding.Play_Video, skip_selector=False, player=None): """ scrapes for music sources using NaN scraper library Args: title: song title artist: song artist timeout: timeout for scraping link preset: preferred quality of stream dialog: dialog to use for displaying messages exclude: list of scrapers to exclude Returns: Boolean indicating playback success """ title = title allow_debrid = ADDON.getSetting('allow_debrid') == "true" if ADDON.getSetting('use_link_dialog') == 'true' and not skip_selector: link, rest = nanscrapers.scrape_song_with_dialog( title, artist, timeout=timeout, exclude=exclude, enable_debrid=allow_debrid, extended=True) if type(link) == dict and "path" in link: link = link["path"] if link is None: return False url = link['url'] if ADDON.getSetting('link_fallthrough') == 'true': played = False index = 0 links = [] for item in rest: 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:] num_results = len(rest) + 1 while not played: try: if dialog is not None and dialog.iscanceled(): return if dialog is not None: index = index + 1 percent = int((index * 100) / num_results) line = "%s - %s (%s)" % (link['scraper'], link['source'], link['quality']) dialog.update(percent, line) except: pass try: played = output_function( url, showbusy=False, ignore_dp=True, item=listitem, player=player) link = links[0] links = links[1:] except: return False return played else: return output_function( url, showbusy=False, ignore_dp=True, item=listitem, player=player) links_scraper = nanscrapers.scrape_song( title, artist, timeout=timeout, exclude=exclude, enable_debrid=allow_debrid) sd_links = [] num_scrapers = len(nanscrapers.relevant_scrapers()) index = 0 try: for scraper_links in links_scraper(): if dialog is not None and dialog.iscanceled(): return if dialog is not None: index = index + 1 percent = int((index * 100) / num_scrapers) dialog.update(percent) 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 Sources().__check_skip_pairing(scraper_link): continue quality = Sources.__determine_quality( scraper_link["quality"]) preset = preset.lower() if preset == 'searchsd': if quality == "HD": continue elif preset == "search": if quality == "SD": sd_links.append(scraper_link) result = output_function( scraper_link["url"], showbusy=False, ignore_dp=True, item=listitem, player=player) if result: return result for scraper_link in sd_links: if dialog is not None and dialog.iscanceled(): return result = output_function( scraper_link["url"], showbusy=False, ignore_dp=True, item=listitem, player=player) if result: return result except: pass return False
def get_music_sources(title, artist, timeout=30, preset="search", dialog=None, exclude=None, listitem=None, output_function=koding.Play_Video): """ scrapes for music sources using NaN scraper library Args: title: song title artist: song artist timeout: timeout for scraping link preset: preferred quality of stream dialog: dialog to use for displaying messages exclude: list of scrapers to exclude Returns: Boolean indicating playback success """ title = title allow_debrid = ADDON.getSetting('allow_debrid') == "true" links_scraper = nanscrapers.scrape_song( title, artist, timeout=timeout, exclude=exclude, enable_debrid=allow_debrid) sd_links = [] num_scrapers = len(nanscrapers.relevant_scrapers()) index = 0 for scraper_links in links_scraper(): if dialog is not None and dialog.iscanceled(): return if dialog is not None: index = index + 1 percent = int((index * 100) / num_scrapers) dialog.update(percent) 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 Sources().__check_skip_pairing(scraper_link): continue quality = Sources.__determine_quality( scraper_link["quality"]) preset = preset.lower() if preset == 'searchsd': if quality == "HD": continue elif preset == "search": if quality == "SD": sd_links.append(scraper_link) result = output_function(scraper_link["url"], showbusy=False, ignore_dp=True, item=listitem) if result: return result for scraper_link in sd_links: if dialog is not None and dialog.iscanceled(): return result = output_function(scraper_link["url"], showbusy=False, ignore_dp=True, item=listitem) if result: return result return False