reddit-image-wall-getter/reddit_imgs/system/downloader/modules/direct_link.py

52 lines
1.5 KiB
Python
Raw Normal View History

2017-12-29 22:54:22 +00:00
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
from ..downloadedData import DownloadedData
from ... import simpleDownloader
def works_on(domain):
return domain=='direct_link'
class DirectLink(object):
def recognizes(self, link):
if (
link.startswith('http://u18chan.com/')
or
link.startswith('https://u18chan.com/')
or
link.startswith('http://dl.dropboxusercontent.com')
or
link.startswith('https://dl.dropboxusercontent.com')
2018-01-07 03:57:39 +00:00
or
link.startswith('http://pawsru.org')
or
link.startswith('https://pawsru.org')
2017-12-29 22:54:22 +00:00
):
return False
return True
2018-01-07 03:57:39 +00:00
def needsPromiscuity(self, link):
if (
link.startswith('http://cdn.discordapp.com')
or
link.startswith('https://cdn.discordapp.com')
or
link.startswith('http://www.weasyl.com')
or
link.startswith('https://www.weasyl.com')
):
return True
return False
2017-12-29 22:54:22 +00:00
def download(self, link):
dd = DownloadedData()
simpleDownloader.cleanCookies()
2018-01-07 03:57:39 +00:00
bts = simpleDownloader.getUrlBytes(link, self.needsPromiscuity(link))
2017-12-29 22:54:22 +00:00
simpleDownloader.cleanCookies()
if bts is not None:
dd.put(link,bts)
return dd
def get_class():
return DirectLink