Skip to content

Commit

Permalink
Merge pull request #689 from ArjixWasTaken/patch-32
Browse files Browse the repository at this point in the history
Improved the logic of the extractor selection in animerush
  • Loading branch information
AbdullahM0hamed committed Jun 25, 2021
2 parents 9e3df85 + a30b5af commit 01f44f6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
9 changes: 8 additions & 1 deletion anime_downloader/extractors/yourupload.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@

from anime_downloader.extractors.base_extractor import BaseExtractor
from anime_downloader.sites import helpers
from requests.exceptions import HTTPError

logger = logging.getLogger(__name__)


class Yourupload(BaseExtractor):
def _get_data(self):
regex = r"file: '([^']*)"
file = re.search(regex, helpers.get(self.url).text).group(1)
try:
response = helpers.get(self.url)
except HTTPError:
logger.error('File not found.')
return {'stream_url': ''}

file = re.search(regex, response.text).group(1)
return {
'stream_url': file,
'referer': self.url
Expand Down
20 changes: 15 additions & 5 deletions anime_downloader/sites/animerush.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from anime_downloader.sites.anime import Anime, AnimeEpisode, SearchResult
from anime_downloader.sites import helpers
from anime_downloader.extractors import get_extractor
from anime_downloader.extractors.init import ALL_EXTRACTORS

import logging
import re

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -41,12 +43,20 @@ def _get_sources(self):
sources_list = []
# Sources [0] is the url [1] is the name of the source
# eg: [['https://mp4upload.com/embed-r07potgdvbkr-650x370.html', 'Mp4upload Video']]
domain_regex = r"\/\/(?:\w{3,6}\.)?(.*?)\."
for i in sources:
# Not exactly ideal setup for more extractors
# If more advanced sources needs to get added look at watchmovie or darkanime
server = 'yourupload' if 'yourupload' in i[0] else 'mp4upload'
found = False
domain = re.findall(domain_regex, i[0])[0].lower()

for extractor in ALL_EXTRACTORS:
if re.match(extractor['regex'], domain):
found = True

if not found:
continue

sources_list.append({
'extractor': server,
'extractor': domain,
'url': i[0],
'server': i[1],
'version': 'subbed'
Expand Down

0 comments on commit 01f44f6

Please sign in to comment.