52 lines
1.5 KiB
Python
52 lines
1.5 KiB
Python
#!/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')
|
|
or
|
|
link.startswith('http://pawsru.org')
|
|
or
|
|
link.startswith('https://pawsru.org')
|
|
):
|
|
return False
|
|
return True
|
|
|
|
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
|
|
|
|
def download(self, link):
|
|
dd = DownloadedData()
|
|
simpleDownloader.cleanCookies()
|
|
bts = simpleDownloader.getUrlBytes(link, self.needsPromiscuity(link))
|
|
simpleDownloader.cleanCookies()
|
|
if bts is not None:
|
|
dd.put(link,bts)
|
|
return dd
|
|
|
|
def get_class():
|
|
return DirectLink
|