2017-12-29 22:54:22 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
|
|
|
|
from ..downloadedData import DownloadedData
|
|
|
|
from ... import simpleDownloader
|
2020-06-01 03:20:23 +00:00
|
|
|
from ._cacheable import get_link_bytes
|
2017-12-29 22:54:22 +00:00
|
|
|
|
|
|
|
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')
|
2018-01-30 23:00:33 +00:00
|
|
|
or
|
|
|
|
'gfycat.com/' in link
|
2020-01-05 03:27:19 +00:00
|
|
|
or
|
|
|
|
'.pximg.net/' in link
|
2020-04-01 03:53:16 +00:00
|
|
|
or
|
|
|
|
'.fbcdn.net/' in link
|
|
|
|
or
|
|
|
|
'cdninstagram.com/' in link
|
|
|
|
or
|
|
|
|
'dropbox.com/' in link
|
|
|
|
or
|
|
|
|
'patreonusercontent.com/' in link
|
|
|
|
or
|
|
|
|
'<!--' in link
|
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')
|
2020-05-13 21:07:05 +00:00
|
|
|
or
|
|
|
|
link.startswith('https://giant.gfycat.com')
|
|
|
|
or
|
|
|
|
link.startswith('https://hitomi.la')
|
|
|
|
or
|
|
|
|
'.hitomi.la/' in link
|
|
|
|
or
|
|
|
|
'pornreactor.cc' in link
|
|
|
|
or
|
|
|
|
'u18chan.com' in link
|
2020-06-01 03:20:23 +00:00
|
|
|
or
|
|
|
|
's3.amazonaws.com/' in link
|
|
|
|
or
|
|
|
|
'//data.tumblr.com/' in link
|
|
|
|
or
|
|
|
|
'//ve.media.tumblr.com/' in link
|
|
|
|
or
|
|
|
|
'//redgifs.com/' in link
|
|
|
|
or
|
|
|
|
'.redgifs.com/' in link
|
2018-01-07 03:57:39 +00:00
|
|
|
):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
2017-12-29 22:54:22 +00:00
|
|
|
def download(self, link):
|
|
|
|
dd = DownloadedData()
|
|
|
|
simpleDownloader.cleanCookies()
|
2020-06-01 03:20:23 +00:00
|
|
|
bts = get_link_bytes(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
|