Exemplo n.º 1
0
class the_pirate_bay(object):
    """ the_pirate_bay module for we-get.
    """
    def __init__(self, pargs):
        self.links = None
        self.pargs = pargs
        self.action = None
        self.search_query = None
        self.module = Module()
        self.parse_pargs()
        self.items = dict()

    def parse_pargs(self):
        for opt in self.pargs:
            if opt == "--search":
                self.action = "search"
                self.search_query = self.pargs[opt][0].replace(' ', '-')
            elif opt == "--list":
                self.action = "list"

    def _parse_data(self, data):
        data = data.replace('\t', '').replace('\n', '')
        items = re.findall(
            r'<div class=\"detName\">(.*?)<div class=\"detName\">', data)
        seeds = None
        leeches = None
        magnet = None

        for item in items:
            seeds, leeches = re.findall(r'<td align=\"right\">(\d+)</td>',
                                        item)
            magnet = re.findall(r'href=[\'"]?([^\'">]+)', item)[1]
            user_status = re.findall(r'<img.+title="(Trusted|VIP)"', item)
            try:
                user_status = user_status[0].lower()
            except IndexError:
                user_status = None
            name = self.module.fix_name(self.module.magnet2name(magnet))
            self.items.update({
                name: {
                    'seeds': seeds,
                    'leeches': leeches,
                    'link': magnet,
                    'user_status': user_status
                }
            })

    def search(self):
        url = "%s%s" % (BASE_URL, SEARCH_LOC % (self.search_query))
        data = self.module.http_get_request(url)
        self._parse_data(data)
        return self.items

    def list(self):
        url = "%s%s" % (BASE_URL, LIST_LOC)
        data = self.module.http_get_request(url)
        self._parse_data(data)
        return self.items
Exemplo n.º 2
0
class eztv(object):
    """ eztv module for we-get.
    """
    def __init__(self, pargs):
        self.links = None
        self.pargs = pargs
        self.action = None
        self.search_query = None
        self.module = Module()
        self.parse_pargs()
        self.items = dict()

    def parse_pargs(self):
        for opt in self.pargs:
            if opt == "--search":
                self.action = "search"
                self.search_query = self.pargs[opt][0].replace(' ', '-')
            elif opt == "--list":
                self.action = "list"

    def _parse_data(self, data):
        data = data.replace('\t', '').replace('\n', '')
        items = re.findall(r'<tr name=\"hover\" class=\"forum_header_border\">(.*?)</tr>', data)
        seeds = None
        leeches = None
        magnet  = None

        for item in items:
            if "magnet:" in item:
                try:
                    seeds = re.findall(r'<font color=\"green\">(.*?)</font>', item)[0]
                    # In case seeds will be 1,212
                    seeds = seeds.replace(',', '')
                except IndexError:
                    seeds = '0'
                    # EZTv will not return lecches ):
                    leeches = "?"
                magnet = re.findall(r'href=[\'"]?([^\'">]+)', item)[2]
                name = self.module.fix_name(self.module.magnet2name(magnet))
                self.items.update( { name : { 'seeds' : seeds, 'leeches' : leeches, 'link' : magnet} })

    def search(self):
        url = "%s%s" % (BASE_URL, SEARCH_LOC % (self.search_query))
        data = self.module.http_get_request(url)
        self._parse_data(data)
        return self.items

    def list(self):
        url = "%s%s" % (BASE_URL, LIST_LOC)
        data = self.module.http_get_request(url)
        self._parse_data(data)
        return self.items
Exemplo n.º 3
0
class leetx(object):
    """ 1337x module for we-get.
    """
    def __init__(self, pargs):
        self.links = None
        self.pargs = pargs
        self.action = None
        self.search_query = None
        self.module = Module()
        self.parse_pargs()
        self.items = dict()
        self.results = 10  # Limit the results to avoid blocking.

    def parse_pargs(self):
        for opt in self.pargs:
            if opt == "--search":
                self.action = "search"
                self.search_query = self.pargs[opt][0]
            elif opt == "--list":
                self.action = "list"

    def set_item(self, link):
        url = "%s%s" % (BASE_URL, link)
        magnet = None
        data = self.module.http_get_request(url)
        links = re.findall(r'href=[\'"]?([^\'">]+)', data)
        seeders = re.findall(r'<span class=\"seeds\">(.*?)</span>', data)[0]
        leechers = re.findall(r'<span class=\"leeches\">(.*?)</span>', data)[0]
        item = dict()
        name = None

        for link in links:
            if "magnet" in link:
                magnet = link
                break
        name = self.module.fix_name(self.module.magnet2name(magnet))
        item.update(
            {name: {
                'seeds': seeders,
                'leeches': leechers,
                'link': magnet
            }})
        return item

    def search(self):
        url = "%s%s" % (BASE_URL, SEARCH_LOC % (quote_plus(self.search_query)))
        data = self.module.http_get_request(url)
        links = re.findall(r'href=[\'"]?([^\'">]+)', data)
        results = 0

        for link in links:
            if "/torrent/" in link:
                if results == self.results:
                    break
                item = self.set_item(link)
                self.items.update(item)
                results += 1
        return self.items

    def list(self):
        url = "%s%s" % (BASE_URL, LIST_LOC)
        data = self.module.http_get_request(url)
        links = re.findall(r'href=[\'"]?([^\'">]+)', data)
        results = 0

        for link in links:
            if "/torrent/" in link:
                if results == self.results:
                    break
                item = self.set_item(link)
                self.items.update(item)
                results += 1
        return self.items