nzbindex.com search 'improvements'

Enhancement requests or feature requests for future Mylar releases.
Post Reply
ebbnflow
Posts: 5
Joined: Mon Aug 27, 2018 12:48 am

nzbindex.com search 'improvements'

Post by ebbnflow » Sun Sep 09, 2018 4:08 am

I've been unable to get a comic that started in 2015 (descender - which I own the hard copies). Mylar just doesn't find them. Doing a mylar manual search doesn't find them either. So today I wrote a python script that parsed the nxbindex.com rss feed to find all the issues I was looking for. I was able to use the sabnzb api to send requests over. They then were postprocessed and mylar picked them up properly.

Here's my script. It's not perfect; and needs some more work but it did't the job. If you think it might help, toss it into your code. The regex isn't perfect but it worked for me.

Code: Select all

import feedparser
import urllib2
import re
import urllib


def add_comics_by_url(url):
    encoded_url = urllib.quote(url)
    return _action("addbyurl", category="comics", url=encoded_url)


def _action(name, **kwargs):
    command_string_key = "commandstring"
    config_dict = {"host": "<yoursabnzbhost>", "port": "8080", 'apikey': '<yourApiKey>'}
    dict_actions = {
        "addbyurl": {
            "commandstring": "http://{host}:{port}/sabnzbd/api?apikey={apikey}&output=json&mode=addurl&name={url}&cat={category}"
        }
    }
    config_dict.update(kwargs)
    command_string = dict_actions[name].get(command_string_key)
    response = urllib2.urlopen(command_string.format(**config_dict))
    return response.read()


def search_issue(name, regex_filter, issue_numbers):
    feed_obj = feedparser.parse(name)
    for feed_item in feed_obj.entries:
        print feed_item.title
        search_results = re.search(regex_filter, feed_item.title, re.IGNORECASE)
        current_issue = search_results.group(1)
        print "current issue: " + current_issue
        removed_leading_zeroes = re.sub("^[0]{1,4}", "", current_issue)
        matched = removed_leading_zeroes in issue_numbers
        # matched = re.match(removed_leading_zeroes, issue_number)
        # print "matched: " + str(matched != None)
        print "matched: " + str(matched)
        print "################################################################"
        if matched:
            print "sending nzb to sab"
            download_link = [f for f in feed_item.links if f['type'] == 'text/xml'][0]
            results = add_comics_by_url(download_link['href'])
            print results

# to do
# add caching and filtering .... the code currently sends any matches to sab... including multiple matches
# for the same issue....

if __name__ == "__main__":
    url = "https://www.nzbindex.com/rss/?q={name}&sort=agedesc&max=1000&more=1"
    name = "descender"
    regex_filter = name+"[^0-9]*(\d+(\.\d+)?)"
    issue_numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "11", "12", "13", "14", "15", "16", "17", "18", "19", "21", "22", "23", "24", "25"]
    search_url = url.format(name=name)
    search_issue(search_url, regex_filter, issue_numbers)

# Add NZB by URL
# Add NZB using an URL that needs to be accessible by SABnzbd, so make sure to include authentication information if the Indexer requires it. Example of a full request with everything set to default values is shown below, but only the name parameter is required.
# http://host:port/sabnzbd/api?apikey=<herpderp>&mode=addurl&name=https%3A%2F%indexer.info%2Fget.php%3Fguid%3Ded731c0b37f25f84aea563d6ddb210b1%26api%3D6f235b80fab0c76e1ce7da21b2c6c48c&nzbname=&cat=*&script=Default&priority=-100&pp=-1
# &cat=comics


Post Reply