示例#1
0
 def show(self):
     for row in self.sqldata:
         date = self.format_date(row[0])
         name = U.snip(self.episode(row[1], row[4], row[5]), 25)
         name = name.ljust(25)
         filename = self.exists(row[2])
         print '%s  %s  %s' % (date, name, filename)
示例#2
0
 def exists(self, filename):
     ok = 76
     missing = 160
     if filename is None:
         return ''
     elif os.path.exists(filename):
         filename = filename
     else:
         filename = U.effects(['blackf', 'strikeon'], filename)
     return filename
示例#3
0
    def search(self, search_string, season=False, episode=False):
        #http://bitsnoop.com/search/all/supernatural+s01e01+OR+1x01/c/d/1/?fmt=rss

        if season and episode:
            search_string = '%s' % (
                self.se_ep(
                    season, episode, search_string))

        query = search_string
        encoded_search = urllib.quote(query)
        url = 'http://bitsnoop.com/search/all/{}/c/d/1/?fmt=rss'
        full_url = url.format(encoded_search)

        parsed = feedparser.parse(full_url)
        header = [
            [search_string, full_url],
            ['Name', 'Size', 'Date', 'Seeds'],
            [0, 10, 6, 6],
            ['<', '>', '=', '>']]
        show_data = []

        for show in parsed['entries']:
            #pp(show)

            if show['published_parsed']:
                dt = datetime.fromtimestamp(mktime(show['published_parsed']))
                date = dt.strftime('%b %d/%Y')
            else:
                date = '-'
            size = U.pretty_filesize (show['size'])
            title = show['title']
            seeds = show['numseeders']
            magnet = show['magneturi']

            show_data.append([
                title,
                size,
                date,
                seeds,
                magnet
            ])

        show_data.sort(key=lambda x: int(x[3]), reverse=True) # sort by seeds
        return [header] + [show_data]
示例#4
0
    def search(self, search_string, season=False, episode=False):

        if season and episode:
            search_string = '%s' % (
                self.se_ep(
                    season, episode, search_string))

        query = search_string
        encoded_search = urllib.quote (query)
        url = '{}/usearch/%s/?rss=1&field=seeders&sorder=desc'.format(self.provider_url)
        full_url = url % encoded_search

        parsed = feedparser.parse(full_url)
        header = [
            [search_string, full_url],
            ['Name', 'Size', 'Date', 'Seeds'],
            [0, 10, 12, 6],
            ['<', '>', '<', '>']]
        show_data = []

        for show in parsed['entries']:
            dt = datetime.fromtimestamp(mktime(show['published_parsed']))
            date = dt.strftime('%b %d/%Y')

            size = U.pretty_filesize (show['torrent_contentlength'])

            # title = U.snip (show['title'].ljust (title_w), title_w)
            # title = title.replace ('avi', U.fg_color ('green', 'avi'))
            title = show['title']

            show_data.append([
                title,                    # title
                size,                     # show size
                date,                     # date
                show['torrent_seeds'],    # seeds
                show['torrent_magneturi'] # id (download magnet url)
            ])

        #show_data.sort(key=lambda x: int(x[3]), reverse=True) # sort by seeds
        return [header] + [show_data]
示例#5
0
    def search(self, search_string, season=False,
               episode=False):
        """
        Return an array of values:

        [
          [
            ['Title string', 'search url'],
            [head1, head2, head3, id],
            [head1-width, head2-width, head3-width],
            [head1-alignment, head2-alignment, head3-alignment]
          ],
          [
            [<column 1 data>, <column 2 data>, <column 3 data>, <id>],
            [<column 1 data>, <column 2 data>, <column 3 data>, <id>],
            # etc...
          ]
        ]
        """

        self.season = season
        self.episode = episode
        self.show_name = search_string

        msg = u'Searching for: {0:s}...'.format(search_string)
        msg = U.hi_color(msg, foreground=16, background=184)
        sys.stdout.write(msg)
        sys.stdout.flush()
        backspace = '\b' * len(msg)
        overwrite = ' ' * len(msg)

        search_results = self.engine.search(search_string, season, episode)

        print '%s%s' % (backspace, overwrite),

        return search_results
示例#6
0
    def generate(self):
        title_bar = U.hi_color(
            '|',
            foreground=self.colors['bar'],
            background=self.colors['header_bg']
        )
        bar = U.hi_color(
            '|',
            foreground=self.colors['bar']
        )

        # TITLE --------------------------------------------
        titletext = ('  ' + self.table.title.text).ljust(self.console_columns)
        title = U.effects(['boldon'], U.hi_color(
            titletext,
            foreground=self.colors['title_fg'],
            background=self.colors['title_bg'],
        ))
        print title

        # HEADER ROW ---------------------------------------
        header = self.table.header
        header_row = [U.hi_color(' ',     # the number/letter column
                                 background=self.colors['header_bg'],
                                 foreground=self.colors['header_fg'])]
        NUMBER_SPACE = 1
        BAR_COUNT = len(header.widths)
        flex_width = self.console_columns - sum(header.widths) - NUMBER_SPACE - BAR_COUNT

        for i, title, width, alignment in zip(range(len(header.widths)), header.titles, header.widths, header.alignments):
            if width == 0:
                width = flex_width
            if alignment == '<':
                title = title[:width].ljust(width)
            elif alignment == '>':
                title = title[:width].rjust(width)
            elif alignment == '=':
                title = title[:width].center(width)
            else:
                title = title[:width].ljust(width)

            header_row.append(
                U.hi_color(
                    title,
                    background=self.colors['header_bg'],
                    foreground=self.colors['header_fg']
                )
            )
        header_row = title_bar.join(header_row)

        print header_row

        # BODY ROWS -----------------------------------------

        # key has the s, r, q, m removed to not interfere with the
        # ask_user options.  This list can have anything, as long as
        # they are single characters.
        key = ('a','b','c','d','e','f','g','h','i','j','k',
               'l','n','o','p','t','u','v','w','x','y','z')

        self.table.body = self.table.body[:self.display_count]
        for row, counter in zip(self.table.body, key):
            # look through the title cell to see if any have 720 or 1080 in the
            # string and mark this row as high def if so.
            is_hidef = False
            if '720p' in row[0] or '1080p' in row[0]:
                is_hidef = True

            row_arr = [counter]
            for i, width, align in zip(row, header.widths, header.alignments):
                i = str(i)
                if width == 0:
                    width = flex_width
                row_item = i.encode('ascii', 'ignore')
                row_item = U.snip(row_item, width)
                row_item = row_item.strip()

                if align == '<':
                    row_item = row_item.ljust(width)
                if align == '>':
                    row_item = row_item.rjust(width)
                if align == '=':
                    row_item = row_item.center(width)
                else:
                    row_item = row_item.ljust(width)

                # if hi dev, set the foreground to green
                if is_hidef:
                    row_item = U.hi_color(row_item, foreground=76)

                row_arr.append(row_item)
            print bar.join(row_arr)

        # USER INPUT ---------------------------------------
        choice = False
        while not choice:
            if self.is_postdownload:
                choice = self.ask_postdownload(key)
            else:
                choice = self.ask(key)
        return choice
示例#7
0
 def display_error(self, message):
     print
     print U.hi_color('[!]', 16, 178), U.hi_color(message, 178)
示例#8
0
    def search(self, search_string, season=False, episode=False):

        """
        Default Search: Our default is prefix match
        Search 123 will match 123, 1234, 1234abcdefg
        Search 123 will not match 0123, ab123, ab123yz

        AND search:
        -----------
        the words hello and world:
        hello world

        NOT search:
        -----------
        the word hello but NOT the word world:
        hello -world

        We can't do NOT only search
        -world

        OR search:
        ----------
        the words hello or world:
        hello or world

        Each "or" is treated as new query part
        hello abcd or hello efgh != hello abcd or efgh

        grouping:
        ---------
        the exact phrase hello world:
        "hello world"
        """

        if season and episode:
            search_string = "%s" % (self.se_ep(season, episode, search_string))

        # print search_string
        url = "http://www.nzbclub.com/nzbrss.aspx?"
        query = {
            "q": search_string,
            "ig": 2,  # hide adult: 1=yes, 2=no
            "szs": 15,  # min size: 15=75m, 16=100m,
            "sze": 24,  # max size: 24=2gig
            "st": 5,  # sort.  5=relevence, 4=size (smallest first)
            "ns": 1,  # no spam
            "sp": 1,  # don't show passworded files
            "nfo": 0,  # has to have nfo  1=yes, 0=no
        }
        full_url = url + urllib.urlencode(query)
        parsed = feedparser.parse(full_url)

        header = [[search_string, full_url], ["Name", "Date", "Size"], [0, 12, 10], ["<", "<", ">"]]

        show_data = []
        for show in parsed["entries"]:
            dt = datetime.fromtimestamp(mktime(show["published_parsed"]))
            date = dt.strftime("%b %d/%Y")

            size = U.pretty_filesize(show["links"][0]["length"])

            show_data.append([show["title"], date, size, show["links"][0]["href"]])  # id

        return [header] + [show_data]
示例#9
0
    def search(self, search_string, season=False, episode=False):
        """
        Search options:
        ---------------
        Minimum age:	 days
        Sort by:         agedesc, age, sizedesc, size
        Minimum size:	 MB
        Maximum size:	 MB
        Default query:
        Poster:
        NFO content:
        Has NFO file
        Hide crossposts
        Show complete releases only  1
        Hide possible spam           1


        Searching
        ---------

        In the default search form you can enter search terms you would like
        to search for. After searching the results shown will match ALL search
        terms entered. For example, if you search for

        foo bar

        all search results will contain both 'foo' AND 'bar'.

        Instead of using ALL terms you can also search for only one (or a few)
        of the terms. To do this you need to use the '|' symbol. For example,
        to search for either 'foo' or 'bar' you can enter the search term

        foo | bar

        On some occasions you would like to exclude results with certain words
        from your search. For example, if you want the word 'foo', but not
        'bar' in your search results you can enter

        foo -bar

        The last option we offer is to search for a sentence that should match
        exactly. In case of 'foo bar' these two words will not necessarily
        turn up next to each other in the search results. If you would like to
        search for some group of words you can put double-quotes around the
        terms. When you need 'foo' and 'bar' to be next to each other the
        correct search would be:

        "foo bar"

        You can't use more than 20 keywords when searching.



        Top level of data structure returned from NZBIndex:
        ---------------------------------------------------
        bozo        ?
        encoding    u'UTF-8'
        entries     all shows                           results['entries'][0...x]
        feed        info about the feed                 results['feed']
        headers
        href        the rss link for these results
        namespaces  ?
        status      200
        version     u'rss20'


        Example of one show entry (results['entries'][0]):
        --------------------------------------------------

          summary_detail
          ----------------
          {'base': u'http://nzbindex.com/rss/?q=American+Horror+Story+S02E09&sort=agedesc&maxsize=5000&minage=0&complete=1&minsize=100&max=100&more=1',
           'type': u'text/html', 'value': u'<p><font color="gray">alt.binaries.boneless, alt.binaries.cores, alt.binaries.multimedia, alt.binaries.town</font><br />\n<b>1.15 GB</b><br />\n19.6 dagen<br />\n<font color="#3DA233">16 bestanden (3098 delen)</font>\n<font color="gray">door Profess0r &lt;[email protected]&gt;</font><br />\n<font color="#E2A910">\n5 PAR2 | 11 ARCHIEF</font>\n</p>',
           'language': None}

          published_parsed
          ----------------
          time.struct_time(tm_year=2012, tm_mon=12, tm_mday=13, tm_hour=4, tm_min=58, tm_sec=19, tm_wday=3, tm_yday=348, tm_isdst=0)

          links
          ----------------
          [{'href': u'http://nzbindex.com/release/80986743/TOWNwww.town.ag-partner-of-www.ssl-news.info-American.Horror.Story.S02E09.720p.HDTV.X264-DIMENSION-0116-American.Horror.Story.S02E09.720p.HDTV.X2.nzb',
            'type': u'text/html',
            'rel': u'alternate'},
           {'length': u'1233191350',
            'href': u'http://nzbindex.com/download/80986743/TOWNwww.town.ag-partner-of-www.ssl-news.info-American.Horror.Story.S02E09.720p.HDTV.X264-DIMENSION-0116-American.Horror.Story.S02E09.720p.HDTV.X2.nzb',
            'type': u'text/xml',
            'rel': u'enclosure'}]

          title
          ----------------
          <TOWN><www.town.ag > <partner of www.ssl-news.info > American.Horror.Story.S02E09.720p.HDTV.X264-DIMENSION [01/16] - "American.Horror.Story.S02E09.720p.HDTV.X264-DIMENSION.par2" - 1,11 GB - yEnc

          tags
          ----------------
          [{'term': u'alt.binaries.boneless', 'scheme': None, 'label': None},
           {'term': u'alt.binaries.cores', 'scheme': None, 'label': None},
           {'term': u'alt.binaries.multimedia', 'scheme': None, 'label': None},
           {'term': u'alt.binaries.town', 'scheme': None, 'label': None}]

          summary
          ----------------
          <p><font color="gray">alt.binaries.boneless, alt.binaries.cores, alt.binaries.multimedia, alt.binaries.town</font><br />
          <b>1.15 GB</b><br />
          19.6 dagen<br />
          <font color="#3DA233">16 bestanden (3098 delen)</font>
          <font color="gray">door Profess0r &lt;[email protected]&gt;</font><br />
          <font color="#E2A910">
          5 PAR2 | 11 ARCHIEF</font>
          </p>

          guidislink
          ----------------
          False

          title_detail
          ----------------
          {'base': u'http://nzbindex.com/rss/?q=American+Horror+Story+S02E09&sort=agedesc&maxsize=5000&minage=0&complete=1&minsize=100&max=100&more=1',
           'type': u'text/plain',
           'value': u'<TOWN><www.town.ag > <partner of www.ssl-news.info > American.Horror.Story.S02E09.720p.HDTV.X264-DIMENSION [01/16] - "American.Horror.Story.S02E09.720p.HDTV.X264-DIMENSION.par2" - 1,11 GB - yEnc',
           'language': None}

          link
          ----------------
          http://nzbindex.com/release/80986743/TOWNwww.town.ag-partner-of-www.ssl-news.info-American.Horror.Story.S02E09.720p.HDTV.X264-DIMENSION-0116-American.Horror.Story.S02E09.720p.HDTV.X2.nzb

          published
          ----------------
          Thu, 13 Dec 2012 05:58:19 +0100

          id
          ----------------
          http://nzbindex.com/release/80986743/TOWNwww.town.ag-partner-of-www.ssl-news.info-American.Horror.Story.S02E09.720p.HDTV.X264-DIMENSION-0116-American.Horror.Story.S02E09.720p.HDTV.X2.nzb


          """

        # search_template = ('nzbindex.com/rss/?q=%s&minage=%s&sort=%s' +
        # '&minsize=%s&maxsize=%s&complete=%s&max=%s&more=1')

        if season and episode:
            search_string = '%s' % (
                self.se_ep(
                    season, episode, search_string))

        search_term = ''
        min_age = '0'
        sort = 'agedesc'  # age, agedesc, size, sizedesc
        min_size = '100'  # mb
        max_size = '1000'  # mb
        complete_only = '1'  # return only complete posts
        max_results = '100'

        url = 'http://nzbindex.com/rss/?'
        query = {
            'q': search_string
            , 'minage': '0'
            , 'sort': 'agedesc'
            , 'minsize': '100'
            , 'maxsize': '5000'
            , 'complete': '1'
            , 'max': '100'  # results per page
            , 'more': '1'
        }

        full_url = url + urllib.urlencode(query)

        # print 'searching...'
        parsed = feedparser.parse(full_url)

        show_data = []
        for show in parsed['entries']:
            dt = datetime.fromtimestamp(mktime(show['published_parsed']))
            date = dt.strftime('%b %d/%Y')

            size = U.pretty_filesize(show['links'][1]['length'])

            show_data.append([
                show['title'],
                date,
                size,
                show['links'][1]['href']
            ])

        header = [
            #'%s  (%s)' % (search_string, self.provider_url),
            [search_string, full_url],
            ['Name', 'Date', 'Size'],
            [0, 12, 10],
            ['<', '<', '>']
        ]

        return [header] + [show_data]