def canAddTorrentRssProvider(name, url, cookies, title_tag): """ See if a Torrent provider can be added """ if not name: return json.dumps({'error': 'Invalid name specified'}) provider_dict = dict( zip([x.get_id() for x in app.torrentRssProviderList], app.torrentRssProviderList)) temp_provider = TorrentRssProvider(name, url, cookies, title_tag) if temp_provider.get_id() in provider_dict: return json.dumps({ 'error': 'Exists as {name}'.format( name=provider_dict[temp_provider.get_id()].name) }) else: validate = temp_provider.validate_rss() if validate['result']: return json.dumps({'success': temp_provider.get_id()}) else: return json.dumps({'error': validate['message']})
def canAddTorrentRssProvider(name, url, cookies, title_tag): """See if a Torrent provider can be added.""" if not name: return json.dumps({'error': 'Invalid name specified'}) found_chars = [c for c in INVALID_CHARS if c in name] if found_chars: return json.dumps({ 'error': 'Invalid character in provider name: {0}'.format( ', '.join(found_chars)) }) provider_dict = dict( list( zip([x.get_id() for x in app.torrentRssProviderList], app.torrentRssProviderList))) temp_provider = TorrentRssProvider(name, url, cookies, title_tag) if temp_provider.get_id() in provider_dict: return json.dumps({ 'error': 'Provider name already exists as {name}'.format( name=provider_dict[temp_provider.get_id()].name) }) else: validate = temp_provider.validate_rss() if validate['result']: return json.dumps({'success': temp_provider.get_id()}) else: return json.dumps({'error': validate['message']})
def _save_rsstorrent_providers(providers_settings): providers = [] settings = providers_settings.split('!!!') providers_dict = dict( list(zip([x.get_id() for x in app.torrentRssProviderList], app.torrentRssProviderList))) for provider_settings in settings: if not provider_settings: continue name, url, cookies, title_tag = provider_settings.split('|') url = config.clean_url(url) new_provider = TorrentRssProvider(name, url=url, cookies=cookies, title_tag=title_tag) provider_id = new_provider.get_id() # if it already exists then update it if provider_id in providers_dict: providers_dict[provider_id].name = name providers_dict[provider_id].url = url providers_dict[provider_id].cookies = cookies providers_dict[provider_id].title_tag = title_tag else: app.torrentRssProviderList.append(new_provider) providers.append(provider_id) # delete anything that is missing for provider in app.torrentRssProviderList: if provider.get_id() not in providers: app.torrentRssProviderList.remove(provider) # Update the torrentrss provider list app.TORRENTRSS_PROVIDERS = [provider.name for provider in app.torrentRssProviderList]
def saveTorrentRssProvider(name, url, cookies, title_tag): """ Save a Torrent Provider """ if not name or not url: return '0' provider_dict = dict( zip([x.name for x in app.torrentRssProviderList], app.torrentRssProviderList)) if name in provider_dict: provider_dict[name].name = name provider_dict[name].url = config.clean_url(url) provider_dict[name].cookies = cookies provider_dict[name].title_tag = title_tag return '|'.join([ provider_dict[name].get_id(), provider_dict[name].config_string() ]) else: new_provider = TorrentRssProvider(name, url, cookies, title_tag) app.torrentRssProviderList.append(new_provider) return '|'.join( [new_provider.get_id(), new_provider.config_string()])
def _save_rsstorrent_providers(providers_settings): providers = [] settings = providers_settings.split('!!!') providers_dict = dict( list(zip([x.get_id() for x in app.torrentRssProviderList], app.torrentRssProviderList))) for provider_settings in settings: if not provider_settings: continue name, url, cookies, title_tag = provider_settings.split('|') url = config.clean_url(url) new_provider = TorrentRssProvider(name, url=url, cookies=cookies, title_tag=title_tag) provider_id = new_provider.get_id() # if it already exists then update it if provider_id in providers_dict: providers_dict[provider_id].name = name providers_dict[provider_id].url = url providers_dict[provider_id].cookies = cookies providers_dict[provider_id].title_tag = title_tag else: app.torrentRssProviderList.append(new_provider) providers.append(provider_id) # delete anything that is missing for provider in app.torrentRssProviderList: if provider.get_id() not in providers: app.torrentRssProviderList.remove(provider) # Update the torrentrss provider list app.TORRENTRSS_PROVIDERS = [provider.name for provider in app.torrentRssProviderList]
def canAddTorrentRssProvider(name, url, cookies, title_tag): """See if a Torrent provider can be added.""" if not name: return json.dumps({'error': 'Invalid name specified'}) found_chars = [c for c in INVALID_CHARS if c in name] if found_chars: return json.dumps({'error': 'Invalid character in provider name: {0}'.format(', '.join(found_chars))}) provider_dict = dict(list(zip([x.get_id() for x in app.torrentRssProviderList], app.torrentRssProviderList))) temp_provider = TorrentRssProvider(name, url, cookies, title_tag) if temp_provider.get_id() in provider_dict: return json.dumps({'error': 'Provider name already exists as {name}'.format( name=provider_dict[temp_provider.get_id()].name)}) else: validate = temp_provider.validate_rss() if validate['result']: return json.dumps({'success': temp_provider.get_id()}) else: return json.dumps({'error': validate['message']})
def saveTorrentRssProvider(name, url, cookies, title_tag): """Save a Torrent Provider.""" if not name or not url: return '0' provider_dict = dict(list(zip([x.name for x in app.torrentRssProviderList], app.torrentRssProviderList))) if name in provider_dict: provider_dict[name].name = name provider_dict[name].url = config.clean_url(url) provider_dict[name].cookies = cookies provider_dict[name].title_tag = title_tag return '|'.join([provider_dict[name].get_id(), provider_dict[name].config_string()]) else: new_provider = TorrentRssProvider(name, url, cookies, title_tag) app.torrentRssProviderList.append(new_provider) return '|'.join([new_provider.get_id(), new_provider.config_string()])