Пример #1
0
    def on_image_set_as_wallpaper(self, img, meta):
        extraData = meta.get("extraData", None)
        if not extraData:
            return

        download_loc = extraData.get("unsplashDownloadLocation")
        reported = extraData.get("unsplashDownloadReported")
        if download_loc and not reported:
            url = "{}?client_id={}".format(download_loc, UnsplashDownloader.CLIENT_ID)
            Util.fetch(url)
            meta["extraData"]["unsplashDownloadReported"] = True
            Util.write_metadata(img, meta)
Пример #2
0
    def setWallpaperHook(img, meta):
        extraData = meta.get('extraData', None)
        if not extraData:
            return

        download_loc = extraData.get('unsplashDownloadLocation')
        reported = extraData.get('unsplashDownloadReported')
        if download_loc and not reported:
            url = '{}?client_id={}'.format(download_loc,
                                           UnsplashDownloader.CLIENT_ID)
            Util.fetch(url)
            meta['extraData']['unsplashDownloadReported'] = True
            Util.write_metadata(img, meta)
Пример #3
0
    def get_for_search_url(self, url):
        logger.info(lambda: "Fetching quotes from Goodreads for search url=%s" % url)
        html = Util.fetch(url)
        try:
            page = random.randint(1, int(re.findall('Page 1 of (\d+)', html)[0]))
            url += "&page=%d" % page
            html = Util.fetch(url)
        except Exception:
            pass # probably just one page

        logger.info(lambda: "Used QuotationsPage url %s" % url)

        r = r'.*<dl>(.*)</dl>.*'
        if re.match(r, html, flags=re.M | re.S):
            html = re.sub(r, '<html><body>\\1</body></html>', html, flags=re.M | re.S)
            # without this BeautifulSoup gets confused by some scripts

        return self.get_from_html(url, html)
Пример #4
0
 def test_fetch(self):
     resp = Util.fetch("//google.com")
     self.assertTrue(len(resp) > 0)
Пример #5
0
 def test_fetch(self):
     resp = Util.fetch("//google.com")
     self.assertTrue(len(resp) > 0)