Merge pull request #92 from freddiaN/master

add stream/watch support for masterani
master
Vishnunarayan K I 2018-10-09 21:59:07 +05:30 committed by GitHub
commit ff70ecd804
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 2 deletions

View File

@ -177,7 +177,7 @@ def dl(ctx, anime_url, episode_range, url, player, skip_download, quality,
@click.option(
'--provider',
help='The anime provider (website) for search.',
type=click.Choice(['9anime', 'kissanime', 'twist.moe', 'kisscartoon'])
type=click.Choice(['9anime', 'kissanime', 'twist.moe', 'kisscartoon', 'masterani'])
)
@click.option(

View File

@ -2,9 +2,10 @@ import json
import re
import cfscrape
import logging
import requests
from bs4 import BeautifulSoup
from anime_downloader.sites.anime import BaseAnime, BaseEpisode
from anime_downloader.sites.anime import BaseAnime, BaseEpisode, SearchResult
from anime_downloader.const import desktop_headers
scraper = cfscrape.create_scraper()
@ -56,6 +57,33 @@ class Masterani(BaseAnime):
_api_url = 'https://www.masterani.me/api/anime/{}/detailed'
_episodeClass = MasteraniEpisode
@classmethod
def search(cls, query):
r = requests.get('https://masterani.me/api/anime/filter?',
params={'search': query, 'order': 'relevance_desc'})
logging.debug(r.url)
search_result = r.json()['data']
ret = []
logging.debug('Search results')
for item in search_result:
s = SearchResult(
title=item['title'],
url='https://masterani.me/anime/info/{}'.format(item['slug']),
poster='https://cdn.masterani.me/{}{}'.format(
item['poster']['path'], item['poster']['file']
)
)
logging.debug(s)
ret.append(s)
return ret
def get_data(self):
anime_id = self.url.split('info/')[-1].split('-')[0]
url = self._api_url.format(anime_id)