def versions(url): versions = scrapers.versions(url) if len(versions) == 1: ver, href = versions[0] return _episodes(href) else: di_list = [] for label, version_url in versions: action_url = common.action_url('episodes', url=version_url) ver = cleanstring.version(label) di_list.append(common.diritem(ver, action_url)) return di_list
def versions(url): versions = scrapers.versions(url) if len(versions) == 1: ver, href = versions[0] return _episodes(href) else: di_list = [] for label, version_url in versions: action_url = common.action_url('episodes', url=version_url) ver = cleanstring.version(label) di_list.append(common.diritem(ver, action_url)) if auto_select.settings_is_set('auto_select_version'): desire_version = auto_select.get_version_string() if desire_version != '' and desire_version in ver.lower(): common.notify(heading="Auto picked version", message="Picked {}".format(ver)) return _episodes(versions[0][1]) return di_list
def versions(url): versions = scrapers.versions(url) if len(versions) == 1: ver, href = versions[0] return _episodes(href) else: auto_select = xbmcaddon.Addon().getSetting('auto_select_version') if auto_select == 'true': '''priorities = [('Cantonese', int(xbmcaddon.Addon().getSetting('cantonese_priority'))), ('Mandarin', int(xbmcaddon.Addon().getSetting('mandarin_priority'))), ('Chinese Subtitles', int(xbmcaddon.Addon().getSetting('ch_sub_priority'))), ('English Subtitles', int(xbmcaddon.Addon().getSetting('eng_sub_priority')))]''' '''def sort_key(a): for priority in priorities: if priority[0] in a[0]: return priority[1] return "" for priority in priorities: if priority[0] in versions[0][0]:# Fits the priority list above version, href = versions[0] return _episodes(href)''' def match_str(string): match = re.match(r'Watch online \(([^\)]+)\)$', string) if match: return match.group(1) else: return "" priorities = {'Cantonese': int(xbmcaddon.Addon().getSetting('cantonese_priority')), 'Mandarin': int(xbmcaddon.Addon().getSetting('mandarin_priority')), 'Chinese Subtitles': int(xbmcaddon.Addon().getSetting('ch_sub_priority')), 'English Subtitles': int(xbmcaddon.Addon().getSetting('eng_sub_priority'))} def sort_key(a): try: return priorities[cleanstring.version(a[0])] except Exception as e: print("Icdrama: " + str(e)) return "" versions.sort(key = sort_key) priority_indices = {} for k, v in priorities.items(): L = priority_indices.get(v, []) L.append(k) priority_indices[v] = L min_priority = min(priority_indices.keys()) count = len([label for label, _ in versions if match_str(label) in priority_indices[min_priority]]) if count == 1: version, href = versions[0] return _episodes(href) elif count > 1: di_list = [] for i in range(count): label, version_url = versions[i] action_url = common.action_url('episodes', url=version_url) ver = cleanstring.version(label) di_list.append(common.diritem(ver, action_url)) return di_list # Else create full directory di_list = [] for label, version_url in versions: action_url = common.action_url('episodes', url=version_url) ver = cleanstring.version(label) di_list.append(common.diritem(ver, action_url)) return di_list
def sort_key(a): try: return priorities[cleanstring.version(a[0])] except Exception as e: print("Icdrama: " + str(e)) return ""