示例#1
0
    def fetch_versions(self):
        if self.versions:
            return

        result = session.get(self.url)
        tables = result('.tabel95')
        self.title = tables.find('.titulo').contents()[0].strip()

        for i, table in enumerate(tables[2:-1:2]):
            trs = query(table)('tr')

            release = encode(trs.find('.NewsTitle').text().partition(',')[0])
            release = re.sub('version ', '', release, 0, re.I)

            infos = encode(trs.next().find('.newsDate').eq(0).text())
            infos = re.sub('(?:should)? works? with ', '', infos, 0, re.I)

            for tr in trs[2:]:
                tr = query(tr)
                language = tr('.language')
                if not language:
                    continue

                completeness = encode(language.next().text().partition(' ')[0])
                language = encode(language.text())
                download = tr('a[href*=updated]') or tr('a[href*=original]')
                if not download:
                    continue
                hearing_impaired = \
                    bool(tr.next().find('img[title="Hearing Impaired"]'))
                download = encode(download.attr.href)
                self.add_version(download, language, release, infos,
                                 completeness, hearing_impaired)
示例#2
0
文件: login.py 项目: erwinvanh/Python
def get_current_user(page=None):
    if not page:
        page = session.get('/')

    titles = page('.footer_dropup h4')
    if titles and titles[0].text.startswith('Welcome back'):
        return titles[0].text[13:].strip()
示例#3
0
文件: login.py 项目: erwinvanh/Python
def get_current_user(page=None):
    if not page:
        page = session.get('/')

    titles = page('.footer_dropup h4')
    if titles and titles[0].text.startswith('Welcome back'):
        return titles[0].text[13:].strip()
示例#4
0
    def fetch_versions(self):
        if self.versions:
            return

        result = session.get(self.url)
        tables = result('.tabel95')
        self.title = tables.find('.titulo').contents()[0].strip()

        for i, table in enumerate(tables[2:-1:2]):
            trs = query(table)('tr')

            release = encode(trs.find('.NewsTitle').text().partition(',')[0])
            release = re.sub('version ', '', release, 0, re.I)

            infos = encode(trs.next().find('.newsDate').eq(0).text())
            infos = re.sub('(?:should)? works? with ', '', infos, 0, re.I)

            for tr in trs[2:]:
                tr = query(tr)
                language = tr('.language')
                if not language:
                    continue

                completeness = encode(language.next().text().partition(' ')[0])
                language = encode(language.text())
                download = tr('a[href*=updated]') or tr('a[href*=original]')
                if not download:
                    continue
                hearing_impaired = \
                    bool(tr.next().find('img[title="Hearing Impaired"]'))
                download = encode(download.attr.href)
                self.add_version(download, language, release, infos,
                                 completeness, hearing_impaired)
示例#5
0
    def download(self, filename):
        content = session.get(self.url).content

        if content[:9] == '<!DOCTYPE':
            raise FatalError('Daily Download count exceeded.')

        with open(filename, 'wb') as fp:
            fp.write(content)
示例#6
0
def get_current_user():
    global _current_user

    if _current_user is None:
        page = session.get("/")
        titles = page(".footer_dropup h4")
        if titles and titles[0].text.startswith("Welcome back"):
            _current_user = titles[0].text[13:].strip()
        else:
            _current_user = False

    return _current_user
示例#7
0
def get_current_user():
    global _current_user

    if _current_user is None:
        page = session.get('/')
        titles = page('.footer_dropup h4')
        if titles and titles[0].text.startswith('Welcome back'):
            _current_user = titles[0].text[13:].strip()
        else:
            _current_user = False

    return _current_user
示例#8
0
def search(query):
    results = session.get('/search.php',
                          params={'search': query, 'submit': 'Search'})
    last_url = session.last_url
    if '/search.php' in last_url:
        return [
            Episode(quote(encode(link.attrib['href'])),
                    encode(link.text))
            for link in results('.tabel a')
        ]
    else:
        title = encode(results('.titulo').contents()[0]).strip()
        return [Episode(last_url, title, page=results)]
示例#9
0
def search(query):
    results = session.get('/search.php',
                          params={
                              'search': query,
                              'Submit': 'Search'
                          })
    last_url = session.last_url
    if '/search.php' in last_url:
        return [
            Episode(quote(encode(link.attrib['href'])), encode(link.text))
            for link in results('.tabel a')
        ]
    else:
        title = encode(results('.titulo').contents()[0]).strip()
        return [Episode(last_url, title, page=results)]
示例#10
0
    'Serbian (Cyrillic)': 'srp',
    'Serbian (Latin)': 'srp',
    'Sinhala': 'sin',
    'Slovak': 'slk',
    'Slovenian': 'slv',
    'Spanish (Latin America)': 'spa',
    'Spanish (Spain)': 'spa',
    'Spanish': 'spa',
    'Swedish': 'swe',
    'Tamil': 'tam',
    'Thai': 'tha',
    'Turkish': 'tur',
    'Ukrainian': 'ukr',
    'Vietnamese': 'vie',
}

if __name__ == '__main__':
    from addic7ed_cli.request import session

    page = session.get('/serie/Dexter/8/1/A_Beautiful_Day')

    languages = [option.text
                 for option in page('#filterlang option')
                 if option.text != "All"]

    for language in languages:
        if language not in iso639_3_codes:
            print("Unknown language: {}".format(language))
    print("Check http://www-01.sil.org/iso639-3/codes.asp for a complete list "
          "of ISO 639 codes")
示例#11
0
    'Serbian (Latin)': 'srp',
    'Sinhala': 'sin',
    'Slovak': 'slk',
    'Slovenian': 'slv',
    'Spanish (Latin America)': 'spa',
    'Spanish (Spain)': 'spa',
    'Spanish': 'spa',
    'Swedish': 'swe',
    'Tamil': 'tam',
    'Thai': 'tha',
    'Turkish': 'tur',
    'Ukrainian': 'ukr',
    'Vietnamese': 'vie',
}

if __name__ == '__main__':
    from addic7ed_cli.request import session

    page = session.get('/serie/Dexter/8/1/A_Beautiful_Day')

    languages = [
        option.text for option in page('#filterlang option')
        if option.text != "All"
    ]

    for language in languages:
        if language not in iso639_3_codes:
            print("Unknown language: {}".format(language))
    print("Check http://www-01.sil.org/iso639-3/codes.asp for a complete list "
          "of ISO 639 codes")