Beispiel #1
0
    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']})
Beispiel #2
0
    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']})
Beispiel #3
0
    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']})