def get_anime(url, site): anime = get_anime_class(site) def dictify_anime(a): return dict(title=a.title, url=a.url, sitename=a.sitename, episode_count=len(a)) return json.dumps(dictify_anime(anime(url)))
def anime(anime_url): cls = get_anime_class(anime_url) return cls(anime_url, quality='480p')
def get_anime_episode_2(query, site, episode): provider = get_anime_class(site) result = provider.search(query)[0] anime = provider(result.url) return json.dumps(dictify_episode(anime, episode))
def get_anime_episode(url, site, episode): anime = get_anime_class(site) return json.dumps(dictify_episode(anime(url), episode))
def search_anime(query, site): anime = get_anime_class(site) return json.dumps([ dict(title=a.title, url=a.url, poster=a.poster) for a in anime.search(query) ])
#!/usr/bin/env python3 """ server.py Main server file to allow access to anime-downloader package. """ import os import json import logging from flask import Flask, request, send_from_directory, redirect, url_for from anime_downloader import get_anime_class app = Flask(__name__) AnimeClass = get_anime_class('9anime') EXCLUDED_FILE_CHARS = '/\\:*?"<>| ' EXT_MP4 = '.mp4' def initiliaze(): """ Ran before the server starts. """ app.config['STATIC'] = 'static' app.config['html'] = 'html' app.config['css'] = 'css' app.config['js'] = 'js' app.config['video'] = 'video'
from anime_downloader import get_anime_class import json import logging logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger('urllib3.connectionpool') logger.setLevel(logging.WARNING) NineAnime = get_anime_class("9anime") def search(query): res = NineAnime.search(query) serialized = [{ 'title': x.title, 'url': x.url, 'meta': x.meta, 'poster': x.poster } for x in res] return json.dumps(serialized) # search("fullmetal") def get_stream_url(url, i): try: anime = NineAnime(url) url = anime[i].source().stream_url return url except Exception as e: