parent
47aad5e01b
commit
75634f2145
|
@ -61,6 +61,7 @@ Yeah. Me too! That's why this tool exists.
|
|||
- Animesimple
|
||||
- Animerush
|
||||
- Watchmovie
|
||||
- Nyaa.si
|
||||
- twist.moe - requires Node.js
|
||||
- Kissanime - requires Node.js
|
||||
- Kisscartoon - requires Node.js
|
||||
|
|
|
@ -19,6 +19,7 @@ DEFAULT_CONFIG = {
|
|||
'file_format': '{anime_title}/{anime_title}_{ep_no}',
|
||||
'provider': 'twist.moe',
|
||||
'external_downloader': '',
|
||||
'aria2c_for_torrents': False,
|
||||
},
|
||||
'watch': {
|
||||
'quality': '1080p',
|
||||
|
|
|
@ -20,7 +20,8 @@ ALL_ANIME_SITES = [
|
|||
('ryuanime', 'ryuanime', 'RyuAnime'),
|
||||
('erairaws', 'erai-raws', 'EraiRaws'),
|
||||
('watchmovie','watchmovie','WatchMovie'),
|
||||
('animekisa','animekisa','AnimeKisa')
|
||||
('animekisa','animekisa','AnimeKisa'),
|
||||
('nyaa','nyaa','Nyaa')
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
import re
|
||||
|
||||
from anime_downloader.sites.anime import Anime, AnimeEpisode, SearchResult
|
||||
from anime_downloader.sites import helpers
|
||||
|
||||
class Nyaa(Anime, sitename = 'nyaa'):
|
||||
sitename = 'nyaa'
|
||||
url = f'https://{sitename}.si'
|
||||
@classmethod
|
||||
def search(cls,query):
|
||||
rex = r'(magnet:)+[^"]*'
|
||||
search_results = helpers.soupify(helpers.get(f"https://nyaa.si/?f=2&c=1_2&q={query}&s=seeders&o=desc"))
|
||||
|
||||
search_results = [
|
||||
SearchResult(
|
||||
title = i.select("a:not(.comments)")[1].get("title") + ' | '+ i.find_all('td',class_ = 'text-center')[1].text,
|
||||
url = i.find_all('a',{'href':re.compile(rex)})[0].get('href'))
|
||||
for i in search_results.select("tr.default,tr.success")
|
||||
]
|
||||
|
||||
return search_results
|
||||
|
||||
def _scrape_episodes(self):
|
||||
return [self.url] #the magnet has all episodes making this redundant
|
||||
|
||||
class NyaaEpisode(AnimeEpisode, sitename='nyaa'):
|
||||
def _get_sources(self):
|
||||
return [('no_extractor', self.url,)]
|
|
@ -194,6 +194,10 @@ def format_filename(filename, episode):
|
|||
|
||||
|
||||
def format_command(cmd, episode, file_format, path):
|
||||
from anime_downloader.config import Config
|
||||
if not Config._CONFIG['dl']['aria2c_for_torrents'] and episode.url.startswith('magnet:?xt=urn:btih:'):
|
||||
return ['open',episode.url]
|
||||
|
||||
cmd_dict = {
|
||||
'{aria2}': 'aria2c {stream_url} -x 12 -s 12 -j 12 -k 10M -o '
|
||||
'{file_format}.mp4 --continue=true --dir={download_dir}'
|
||||
|
@ -203,7 +207,7 @@ def format_command(cmd, episode, file_format, path):
|
|||
|
||||
|
||||
rep_dict = {
|
||||
'stream_url': episode.source().stream_url,
|
||||
'stream_url': episode.source().stream_url if not episode.url.startswith('magnet:?xt=urn:btih:') else episode.url,
|
||||
'file_format': file_format,
|
||||
'download_dir': os.path.abspath(path),
|
||||
'referer': episode.source().referer,
|
||||
|
@ -231,6 +235,20 @@ def eval_in_node(js: str):
|
|||
output = subprocess.check_output(['node', '-e', js])
|
||||
return output.decode('utf-8')
|
||||
|
||||
def open_magnet(magnet):
|
||||
if sys.platform.startswith('linux'):
|
||||
subprocess.Popen(['xdg-open', magnet],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
elif sys.platform.startswith('win32'):
|
||||
os.startfile(magnet)
|
||||
elif sys.platform.startswith('cygwin'):
|
||||
os.startfile(magnet)
|
||||
elif sys.platform.startswith('darwin'):
|
||||
subprocess.Popen(['open', magnet],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
else:
|
||||
subprocess.Popen(['xdg-open', magnet],
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
|
||||
def external_download(cmd, episode, file_format, path=''):
|
||||
|
@ -242,13 +260,16 @@ def external_download(cmd, episode, file_format, path=''):
|
|||
|
||||
logger.debug('formatted cmd: ' + ' '.join(cmd))
|
||||
|
||||
p = subprocess.Popen(cmd)
|
||||
return_code = p.wait()
|
||||
if cmd[0] == 'open': #for torrents
|
||||
open_magnet(cmd[1])
|
||||
else:
|
||||
p = subprocess.Popen(cmd)
|
||||
return_code = p.wait()
|
||||
|
||||
if return_code != 0:
|
||||
# Sleep for a while to make sure downloader exits correctly
|
||||
time.sleep(2)
|
||||
sys.exit(1)
|
||||
if return_code != 0:
|
||||
# Sleep for a while to make sure downloader exits correctly
|
||||
time.sleep(2)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def make_dir(path):
|
||||
|
|
Loading…
Reference in New Issue