ali-sajjad-rizavi / super-anime-downloader

A program which takes an Anime name or URL and downloads the specified range of episodes.
30 stars 7 forks source link

This shows whenever I try to download #21

Open Gaurav5760 opened 2 years ago

Gaurav5760 commented 2 years ago

Screenshot_20220201-000249.jpg Screenshot_20220201-000549.jpgScreenshot_20220201-000529.jpg

ali-sajjad-rizavi commented 2 years ago

Ah I see, I'll check this out as soon as I get time... Thanks for reporting! Must be a small fix

silent001 commented 2 years ago

I have done some digging and this appears to be something to do with how mp4download has changed. The url it generates appears to be sound but something is missing like possibly a cookie or something. Sadly my Python skills is not that good so I haven't been able to figure this out yet but I am working on figuring it out. I managed to get a more reliable link generated that doesn't just give a straight 403 error but now I am getting a error with certifactes but when you tell aria2 to download then you tell it

        # Command to use on terminal/cmd for downloading the video using aria2
        options = f'-x 10 --max-tries=5 --retry-wait=10 --check-certificate=false -d downloaded -o "{filename}"'

But I still get this error: image

I will get the scraper to be more flexible (used fixed vaules for now) and share.

Here is what I have so far:

import settings
import models as mdl
from bs4 import BeautifulSoup
import requests
import re

def get_download_link(ep: mdl.Episode) -> str:
    """
    Generates a download link for mp4upload embed video server

    :param ep: Episode model object
    :return: Download link of video from mp4upload
    """
    # The class name for mp4upload server is either "mp4upload" or "mp4"
    embed_url = ep.video_data.get("mp4upload", ep.video_data.get("mp4"))
    if not embed_url:
        return None

    try:
        # Change embed_url to download page url where there is a form
        dl_page_url = embed_url.replace('embed-', '').replace('.html', '')

        # Submit first form to get the next form ***THIS MIGHT NEED COOKIES TO WORK***
        post_params = {'op' : 'download1', 'usr_login' : '', 'id' : '6kw8n2ed8bkp', 'fname' : 'gen1dub.mp4', 'referer' : '', 'method_free' : ' '}
        response = requests.post(dl_page_url, data=post_params, headers=settings.REQUEST_HEADERS)

        # Submit the form and get the returned URL ***THIS MIGHT NEED COOKIES TO WORK***
        post_params = {'op' : 'download2', 'id' : '6kw8n2ed8bkp', 'rand' : '', 'referer' : 'https://www.mp4upload.com/6kw8n2ed8bkp', 'method_free' : ' ', 'method_premium' : ''}
        response = requests.post(dl_page_url, data=post_params, headers=settings.REQUEST_HEADERS)
        download_link = BeautifulSoup(response.text, 'html.parser')

    except Exception as e:
        print(e)
        return None

    return download_link

# A sample Mp4Upload embedded URL: https://www.mp4upload.com/embed-99r0hr81zk9k.html
if __name__ == "__main__":
    print("\t\t=====================")
    print("\t\t Mp4Upload Generator")
    print("\t\t=====================")
    epis = mdl.Episode(
        title="Test title",
        url="Test URL",
        video_data={"embed-servers": {"mp4upload": input("\t- Enter Mp4Upload Embed URL: ")}}
    )
    d = get_download_link(epis)
    print(f"- The generated download link: {d}")