Added 2 extractors and reworked vidstream extractor (#362)
* added hydrax extractor * added cloud9 extractor * added extractors to init * revamped vidstream * added vidstream config * cleaned up vidstream * added comment in vidstream class * updated docs configmaster
parent
213b3d293e
commit
cc401e3c32
|
@ -82,6 +82,9 @@ DEFAULT_CONFIG = {
|
|||
},
|
||||
'animedaisuki': {
|
||||
"servers": ["official"]
|
||||
},
|
||||
'vidstream': {
|
||||
"servers": ["vidstream","gcloud","mp4upload","cloud9","hydrax"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
import re
|
||||
import json
|
||||
import sys
|
||||
from anime_downloader.extractors.base_extractor import BaseExtractor
|
||||
from anime_downloader.sites import helpers
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Cloud9(BaseExtractor):
|
||||
def _get_data(self):
|
||||
url = self.url.replace('https://cloud9.to/embed/','https://api.cloud9.to/stream/')
|
||||
data = helpers.get(url).json()['data']
|
||||
if data == 'Video not found or has been removed':
|
||||
logger.warning('File not found (Most likely deleted)')
|
||||
return {'stream_url': ''}
|
||||
|
||||
return {'stream_url': data['sources'][0]['file']}
|
|
@ -0,0 +1,22 @@
|
|||
import re
|
||||
import json
|
||||
from anime_downloader.extractors.base_extractor import BaseExtractor
|
||||
from anime_downloader.sites import helpers
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class Hydrax(BaseExtractor):
|
||||
def _get_data(self):
|
||||
url = self.url
|
||||
end = url[url.find('=')+1:]
|
||||
beg = json.loads(helpers.post('https://ping.idocdn.com/',
|
||||
data={'slug':end},
|
||||
referer=url,
|
||||
).text)['url']
|
||||
|
||||
link = f'https://{beg}'
|
||||
return {
|
||||
'stream_url': link,
|
||||
'referer': url
|
||||
}
|
|
@ -78,6 +78,18 @@ ALL_EXTRACTORS = [
|
|||
'modulename': 'xstreamcdn',
|
||||
'regex': 'xstreamcdn',
|
||||
'class': 'XStreamCDN'
|
||||
},
|
||||
{
|
||||
'sitename': 'cloud9',
|
||||
'modulename': 'cloud9',
|
||||
'regex': 'cloud9',
|
||||
'class': 'Cloud9'
|
||||
},
|
||||
{
|
||||
'sitename': 'hydrax',
|
||||
'modulename': 'hydrax',
|
||||
'regex': 'hydrax',
|
||||
'class': 'Hydrax'
|
||||
}
|
||||
]
|
||||
|
||||
|
|
|
@ -1,42 +1,77 @@
|
|||
import logging
|
||||
import re
|
||||
import json
|
||||
|
||||
from anime_downloader.config import Config
|
||||
from anime_downloader.extractors.base_extractor import BaseExtractor
|
||||
import anime_downloader.extractors as extractors
|
||||
from anime_downloader.sites import helpers
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class VidStream(BaseExtractor):
|
||||
def _get_data(self):
|
||||
QUALITIES = {
|
||||
"360":[],
|
||||
"480":[],
|
||||
"720":[],
|
||||
"1080":[],
|
||||
}
|
||||
url = self.url.replace('https:////','https://')
|
||||
soup = helpers.get(url).text
|
||||
regex = r'https://vidstreaming\.io/download\?[^"]*'
|
||||
|
||||
if re.search(regex,self.url): #both the download link and stream link can be passed to this
|
||||
download = self.url
|
||||
else:
|
||||
download = re.search(regex,soup).group()
|
||||
'''
|
||||
Config:
|
||||
List of servers. Will use servers in order.
|
||||
For example: ["hydrax","vidstream"] will prioritize the HydraX link.
|
||||
Available servers: links (below) and vidstream
|
||||
'''
|
||||
|
||||
links = {
|
||||
"gcloud":"https://gcloud.live/",
|
||||
"mp4upload":"https://www.mp4upload.com/",
|
||||
"cloud9":"https://cloud9.to",
|
||||
"hydrax":"https://hydrax.net"
|
||||
}
|
||||
|
||||
url = self.url.replace('https:////','https://')
|
||||
url = url.replace('https://vidstreaming.io/download','https://vidstreaming.io/server.php')
|
||||
|
||||
soup = helpers.soupify(helpers.get(url))
|
||||
|
||||
servers = Config._read_config()['siteconfig']['vidstream']['servers']
|
||||
sources_regex = r'sources:(\[{.*?}])'
|
||||
sources = re.search(sources_regex,str(soup))
|
||||
|
||||
linkserver = soup.select('li.linkserver')
|
||||
for a in servers:
|
||||
if a == 'vidstream':
|
||||
return self._get_link(sources)
|
||||
for b in linkserver:
|
||||
if b.get('data-video').startswith(links.get(a,'None')):
|
||||
self.url = b.get('data-video')
|
||||
return extractors.get_extractor(a)._get_data(self)
|
||||
|
||||
def _get_link(self,sources):
|
||||
QUALITIES = {
|
||||
"360":[],
|
||||
"480":[],
|
||||
"720":[],
|
||||
"1080":[],
|
||||
}
|
||||
sources = sources.group(1)
|
||||
sources = sources.replace("'",'"') #json only accepts ""
|
||||
|
||||
regex = r"[{|,][\n]*?[ ]*?[\t]*?[A-z]*?[^\"]:"
|
||||
for a in re.findall(regex,sources): #Because sometimes it's not valid json
|
||||
sources = sources.replace(a,f'{a[:1]}"{a[1:-1]}"{a[-1:]}') #replaces file: with "file":
|
||||
|
||||
sources = json.loads(sources)
|
||||
|
||||
soup = helpers.soupify(helpers.get(download))
|
||||
links = soup.select('div.mirror_link')[0].select('div.dowload > a')
|
||||
|
||||
for a in QUALITIES:
|
||||
for b in links:
|
||||
if a in b.text:
|
||||
QUALITIES[a].append(b.get('href'))
|
||||
for b in sources:
|
||||
if a in b.get('label',None):
|
||||
QUALITIES[a].append(b.get('file',''),)
|
||||
|
||||
stream_url = QUALITIES[self.quality[:-1]][0] if len(QUALITIES[self.quality[:-1]]) != 0 else ''
|
||||
|
||||
|
||||
if QUALITIES == {"360":[],"480":[],"720":[],"1080":[],}:
|
||||
stream_url = links[0].get('href') #In case nothing is found
|
||||
stream_url = sources[0].get('file','') #In case nothing is found
|
||||
loggger.debug("The streaming link's quality cannot be identified.")
|
||||
|
||||
return {
|
||||
'stream_url': stream_url,
|
||||
'referer': download
|
||||
'referer': self.url
|
||||
}
|
||||
|
|
|
@ -20,6 +20,8 @@ The default config file is given below.
|
|||
|
||||
{
|
||||
"dl": {
|
||||
"aria2c_for_torrents": false,
|
||||
"chunk_size": "10",
|
||||
"download_dir": ".",
|
||||
"external_downloader": "{aria2}",
|
||||
"fallback_qualities": [
|
||||
|
@ -30,26 +32,115 @@ The default config file is given below.
|
|||
"file_format": "{anime_title}/{anime_title}_{ep_no}",
|
||||
"force_download": false,
|
||||
"player": null,
|
||||
"provider": "animepahe",
|
||||
"provider": "twist.moe",
|
||||
"quality": "1080p",
|
||||
"skip_download": false,
|
||||
"url": false
|
||||
},
|
||||
"siteconfig": {
|
||||
"animedaisuki": {
|
||||
"servers": [
|
||||
"official"
|
||||
]
|
||||
},
|
||||
"animeflix": {
|
||||
"fallback_servers": [
|
||||
"FastStream"
|
||||
],
|
||||
"server": "AUEngine",
|
||||
"version": "sub"
|
||||
},
|
||||
"animeflv": {
|
||||
"server": "natsuki",
|
||||
"version": "subbed"
|
||||
},
|
||||
"animekisa": {
|
||||
"fallback_servers": [
|
||||
"mp4upload",
|
||||
"vidstream"
|
||||
],
|
||||
"server": "gcloud"
|
||||
},
|
||||
"animerush": {
|
||||
"fallback_servers": [
|
||||
"MP4Upload",
|
||||
"Mp4upload Video",
|
||||
"Youruploads Video"
|
||||
],
|
||||
"server": "Mp4uploadHD Video"
|
||||
},
|
||||
"animesimple": {
|
||||
"server": "trollvid",
|
||||
"version": "subbed"
|
||||
},
|
||||
"anistream.xyz": {
|
||||
"version": "subbed"
|
||||
},
|
||||
"dreamanime": {
|
||||
"server": "trollvid",
|
||||
"version": "subbed"
|
||||
},
|
||||
"dubbedanime": {
|
||||
"servers": [
|
||||
"vidstream",
|
||||
"mp4upload",
|
||||
"trollvid"
|
||||
],
|
||||
"version": "dubbed"
|
||||
},
|
||||
"gogoanime": {
|
||||
"server": "cdn"
|
||||
},
|
||||
"kickass": {
|
||||
"ext_fallback_servers": [
|
||||
"Mp4Upload",
|
||||
"Vidcdn",
|
||||
"Vidstreaming"
|
||||
],
|
||||
"fallback_servers": [
|
||||
"ORIGINAL-QUALITY-V2",
|
||||
"HTML5-HQ",
|
||||
"HTML5",
|
||||
"A-KICKASSANIME",
|
||||
"BETAPLAYER",
|
||||
"KICKASSANIME",
|
||||
"DEVSTREAM"
|
||||
],
|
||||
"server": "A-KICKASSANIME"
|
||||
},
|
||||
"nineanime": {
|
||||
"server": "mp4upload"
|
||||
},
|
||||
"ryuanime": {
|
||||
"server": "trollvid",
|
||||
"version": "subbed"
|
||||
},
|
||||
"vidstream": {
|
||||
"servers": [
|
||||
"vidstream",
|
||||
"gcloud",
|
||||
"mp4upload",
|
||||
"cloud9",
|
||||
"hydrax"
|
||||
]
|
||||
},
|
||||
"watchmovie": {
|
||||
"fallback_servers": [
|
||||
"fembed",
|
||||
"yourupload",
|
||||
"mp4upload"
|
||||
],
|
||||
"server": "gcloud"
|
||||
}
|
||||
},
|
||||
"watch": {
|
||||
"fallback_qualities": [
|
||||
"720p",
|
||||
"480p",
|
||||
"360p"
|
||||
],
|
||||
"log_level": "INFO",
|
||||
"provider": "animepahe",
|
||||
"provider": "twist.moe",
|
||||
"quality": "1080p"
|
||||
}
|
||||
}
|
||||
|
@ -58,3 +149,11 @@ The default config file is given below.
|
|||
- For the key ``file_format``, you can set ``anime_title``\ (which refers to the title of the anime) and ``ep_no`` which is the number of the epiosde.
|
||||
- If you set ``player`` in ``dl``, the tool will never download, only play in the set player.
|
||||
- If you set ``force_download``, it will redownload even if the epiosde has already been downloaded.
|
||||
Choosing preferred server
|
||||
########
|
||||
``server`` contains the preferred server.
|
||||
|
||||
``servers`` contains a list of servers, used in order. Set preferred server by changing the order of the list.
|
||||
|
||||
``fallback_servers`` contains a list of servers to use if the primary server is not found, used in order.
|
||||
|
||||
|
|
Loading…
Reference in New Issue