87 lines
2.5 KiB
Python
87 lines
2.5 KiB
Python
#!/usr/bin/env python3
|
|
# -*- encoding: utf-8 -*-
|
|
|
|
from ..downloadedData import DownloadedData
|
|
from ... import simpleDownloader
|
|
from ._cacheable import get_link_bytes
|
|
|
|
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')
|
|
or
|
|
'gfycat.com/' in link
|
|
or
|
|
'.pximg.net/' in link
|
|
or
|
|
'.fbcdn.net/' in link
|
|
or
|
|
'cdninstagram.com/' in link
|
|
or
|
|
'dropbox.com/' in link
|
|
or
|
|
'patreonusercontent.com/' in link
|
|
or
|
|
'<!--' in link
|
|
):
|
|
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')
|
|
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
|
|
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
|
|
):
|
|
return True
|
|
return False
|
|
|
|
def download(self, link):
|
|
dd = DownloadedData()
|
|
simpleDownloader.cleanCookies()
|
|
bts = get_link_bytes(link, self.needsPromiscuity(link))
|
|
simpleDownloader.cleanCookies()
|
|
if bts is not None:
|
|
dd.put(link,bts)
|
|
return dd
|
|
|
|
def get_class():
|
|
return DirectLink
|