diff --git a/Changelog.md b/Changelog.md index ed9c9db..78cc5a0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -7,4 +7,6 @@ - Support for Whole Show Downloading for Crunchyroll [2017.03.06] - Selection of language for the Crunchyroll Show [2017.03.06] - Downloading only subtitles (skip video downloads) [2017.04.13] -- Fix for [6](https://github.com/Xonshiz/anime-dl/issues/6) and Fix for [3](https://github.com/Xonshiz/anime-dl/issues/3) [2017.04.13] \ No newline at end of file +- Fix for [6](https://github.com/Xonshiz/anime-dl/issues/6) and Fix for [3](https://github.com/Xonshiz/anime-dl/issues/3) [2017.04.13] +- Fix for #9 [2017.04.13] +- Added `Verbose Logging` [2017.04.13] \ No newline at end of file diff --git a/ReadMe.md b/ReadMe.md index f25cd5a..7f97591 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -31,11 +31,13 @@ Anime-dl is a Command-line program to download anime from CrunchyRoll and Funima You can check the list of supported websites [**`HERE`**](https://github.com/Xonshiz/anime-dl/blob/master/Supported_Sites.md). ## Dependencies Installation -This script can run on multiple Operating Systems. But, the script depends on some external binaries or libs. We need `FFmpeg` and `Node.js` in our paths. +This script can run on multiple Operating Systems. But, the script depends on some external binaries or libs. We need `FFmpeg` and `Node.js` in our paths. There are some old streams on Crunchyroll which only support `rtmpe` streams, as noted from Issue #9. For this, you need `rtmpdump`. + +**`These dependencies are required on ALL the operating systems, ALL!.`** 1.) Make sure you have Python installed and is present in your system's path. -2.) Grab [FFmpeg from this link](https://ffmpeg.org/download.html) and [Node.js from this link](https://nodejs.org/en/download/). +2.) Grab [FFmpeg from this link](https://ffmpeg.org/download.html), [Node.js from this link](https://nodejs.org/en/download/) and [RTMPDump](https://www.videohelp.com/software/RTMPDump). 3.) Install FFmpeg and Node.js and place it in the directory of this script, or put them in your system's path. @@ -83,6 +85,7 @@ Currently, the script supports these arguments : -p,--password Indicates password for a website. [REQUIRED] -r,--resolution Indicates the desired resolution. (default = 720p) --skip Skip video downloads (Will only download subtitles) +-v,--verbose Starts Verbose Logging for detailed information. -l,--language Selects the language for the show. (default = Japanese) [Langs = english, dub, sub, Japanese, eng] ``` @@ -130,6 +133,7 @@ This is a very basic and small sript, so at the moment it only have a few featur * Skip if the file has already been downloaded. * Downloads all the episodes for a show available on Crunchyroll. * Gives choice for downloading subs or dubs of a series available on Crunchyroll. +* Choice to download only the subs and skip the videos. ## Changelog You can check the changelog [**`HERE`**](https://github.com/Xonshiz/anime-dl/blob/master/Changelog.md). @@ -138,7 +142,9 @@ You can check the changelog [**`HERE`**](https://github.com/Xonshiz/anime-dl/blo If your're planning to open an issue for the script or ask for a new feature or anything that requires opening an Issue, then please do keep these things in mind. ### Reporting Issues -PLEASE RUN THIS SCRIPT IN A COMMAND LINE (as mentioned in the Usage section) AND DON'T SAY THAT `THE SCRIPT CLOSED TOO QUICK, I COULDN'T SEE`. +PLEASE RUN THIS SCRIPT IN A COMMAND LINE (as mentioned in the Usage section) AND DON'T SAY THAT `THE SCRIPT CLOSED TOO QUICK, I COULDN'T SEE`. If something doesn't work like it's supposed to, run the command with the `--verbose` argument. It'll create a `Error Log.txt` file in the same directory. Upload the content of that file on Github Gists/Pastebin etc. and share that link. + +**Please make sure that you remove your loggin credentials from the Error Log.txt file before you post its contents anywhere.** If you're here to report an issue, please follow the basic syntax to post a request : @@ -146,6 +152,8 @@ If you're here to report an issue, please follow the basic syntax to post a requ **Command Line Arguments You Gave** : The whole command that you gave to execute/run this script. +**Verbose Log Link** : Link to the Gist/Pastebin that holds the content of Error Log.txt. + **Long Explanation** : Describe in details what you saw, what should've happened and what actually happened. This should be enough, but it'll be great if you can add more ;) diff --git a/anime_dl/AnimeDL.py b/anime_dl/AnimeDL.py index b4d7562..f0a8588 100644 --- a/anime_dl/AnimeDL.py +++ b/anime_dl/AnimeDL.py @@ -13,7 +13,7 @@ from sys import exit class AnimeDL(object): - def __init__(self, url, username, password, resolution, language, skipper): + def __init__(self, url, username, password, resolution, language, skipper, logger): website = str(self.honcho(url=url[0])) @@ -24,7 +24,7 @@ class AnimeDL(object): else: sites.crunchyroll.CrunchyRoll( - url=url[0], password=password, username=username, resolution=resolution, language=language, skipper=skipper) + url=url[0], password=password, username=username, resolution=resolution, language=language, skipper=skipper, logger = logger) def honcho(self, url): # print("Got url : %s" % url) diff --git a/anime_dl/__main__.py b/anime_dl/__main__.py index 8601a09..1795d14 100644 --- a/anime_dl/__main__.py +++ b/anime_dl/__main__.py @@ -11,6 +11,8 @@ from AnimeDL import * from sys import exit from version import __version__ import argparse +import logging +import platform class main(object): @@ -26,9 +28,20 @@ class main(object): parser.add_argument('-r', '--resolution', nargs=1, help='Inputs the URL to anime.', default='720p') parser.add_argument('-l', '--language', nargs=1, help='Selects the language for the show.', default='Japanese') parser.add_argument('--skip', action='store_true', help='skips the video download and downloads only subs.') - + parser.add_argument("-v", "--verbose", help="Prints important debugging messages on screen.", + action="store_true") + logger = "False" args = parser.parse_args() + if args.verbose: + logging.basicConfig(format='%(levelname)s: %(message)s', filename="Error Log.log", level=logging.DEBUG) + logging.debug('You have successfully set the Debugging On.') + logging.debug("Arguments Provided : %s" % (args)) + logging.debug( + "Operating System : %s - %s - %s" % (platform.system(), platform.release(), platform.version())) + logging.debug("Python Version : %s (%s)" % (platform.python_version(), platform.architecture()[0])) + logger = "True" + if args.version: print("Current Version : %s" % __version__) exit() @@ -53,4 +66,4 @@ class main(object): if type(args.language) == list: args.language = args.language[0] - AnimeDL(url= args.input, username=args.username, password=args.password, resolution=args.resolution, language=args.language, skipper=skipper) + AnimeDL(url= args.input, username=args.username, password=args.password, resolution=args.resolution, language=args.language, skipper=skipper, logger = logger) diff --git a/anime_dl/sites/crunchyroll.py b/anime_dl/sites/crunchyroll.py index 333cf9b..97f26a3 100644 --- a/anime_dl/sites/crunchyroll.py +++ b/anime_dl/sites/crunchyroll.py @@ -18,10 +18,13 @@ from os import path, makedirs from glob import glob from shutil import move from sys import exit +import logging class CrunchyRoll(object): - def __init__(self, url, password, username, resolution, language, skipper): + def __init__(self, url, password, username, resolution, language, skipper, logger): + if logger == "True": + logging.basicConfig(format='%(levelname)s: %(message)s', filename="Error Log.log", level=logging.DEBUG) Crunchy_Show_regex = r'https?://(?:(?Pwww|m)\.)?(?Pcrunchyroll\.com/(?!(?:news|anime-news|library|forum|launchcalendar|lineup|store|comics|freetrial|login))(?P[\w\-]+))/?(?:\?|$)' Crunchy_Video_regex = r'https?:\/\/(?:(?Pwww|m)\.)?(?Pcrunchyroll\.(?:com|fr)/(?:media(?:-|/\?id=)|[^/]*/[^/?&]*?)(?P[0-9]+))(?:[/?&]|$)' @@ -31,6 +34,7 @@ class CrunchyRoll(object): if Crunchy_Video: cookies, Token = self.webpagedownloader(url=url, username=username[0], password=password[0]) + logging.debug("Cookies : %s\nToken : %s" % (cookies, Token)) if skipper == "yes": self.onlySubs(url=url, cookies=cookies) else: @@ -39,6 +43,7 @@ class CrunchyRoll(object): elif Crunchy_Show: cookies, Token = self.webpagedownloader(url=url, username=username[0], password=password[0]) + logging.debug("Cookies : %s\nToken : %s" % (cookies, Token)) self.wholeShow(url=url, cookie=cookies, token=Token, language=language, resolution=resolution, skipper=skipper) def loginCheck(self, htmlsource): @@ -66,9 +71,12 @@ class CrunchyRoll(object): print("Trying to login...") initialPagefetch = sess.get( url='https://www.crunchyroll.com/login', headers=headers).text + logging.debug("initialPageFetch %s" % initialPagefetch) initialCookies = sess.cookies + logging.debug("initialCokies %s" % initialCookies) csrfToken = search(r'login_form\[\_token\]\"\ value\=\"(.*?)\"', str(initialPagefetch)).group(1) + logging.debug("csrfToken : %s" % csrfToken) # print(csrfToken) payload = { @@ -95,10 +103,28 @@ class CrunchyRoll(object): else: print("Unable to Log you in. Check credentials again.") + def rtmpDump(self, host, file, url, filename): + # print("Downloading RTMP DUMP STREAM!") + logging.debug("Host : %s", host) + logging.debug("file : %s", file) + logging.debug("url : %s", url) + serverAddress = str(host.split("/ondemand/")[0]) + "/ondemand/" + authentication = "ondemand/" + str(host.split("/ondemand/")[1]) + + rtmpDumpCommand = "rtmpdump -r \"%s\" -a \"%s\" -f \"WIN 25,0,0,148\" -W \"http://www.crunchyroll.com/vendor/ChromelessPlayerApp-c0d121b.swf\" -p \"%s\" -y \"%s\" -o \"%s\"" % (serverAddress, authentication, url, file, filename) + logging.debug("rtmpDumpCommand : %s" % rtmpDumpCommand) + + try: + call(rtmpDumpCommand) + except Exception: + print("Please make sure that rtmpdump is present in the PATH or THIS DIRECTORY!") + exit() + def singleEpisode(self, url, cookies, token, resolution): # print("Inside single episode") current_directory = getcwd() video_id = str(url.split('-')[-1]).replace("/", "") + logging.debug("video_id : %s" % video_id) # print("URL : %s\nCookies : %s\nToken : %s\nResolution : %s\nMedia ID : %s" % (url, cookies, token, resolution, video_id)) headers = { 'User-Agent': @@ -113,37 +139,61 @@ class CrunchyRoll(object): sess = create_scraper(sess) if str(resolution).lower() in ['1080p', '1080', 'best', 'fhd']: + logging.debug("Downloading Resolution : %s" % resolution) print("Grabbing Links for 1080p Streams.") infoURL = "http://www.crunchyroll.com/xml/?req=RpcApiVideoPlayer_GetStandardConfig&media_id=%s&video_format=108&video_quality=80¤t_page=%s" % ( video_id, url) + logging.debug("infoURL : %s" % infoURL) xml_page = sess.get( url=infoURL, headers=headers, cookies=cookies).text + logging.debug("xml_page : %s" % xml_page) + + try: + m3u8_link_raw = str( + search(r'\(.*?)\<\/file\>', xml_page).group( + 1)).strip().replace("&", "&") + logging.debug("m3u8_link_raw : %s" % m3u8_link_raw) + if "mp4:" in m3u8_link_raw: + rtmpDL = "True" + hostLink = str( + search(r'\(.*?)\<\/host\>', xml_page).group( + 1)).strip().replace("&", "&") + + except Exception: + print("Error Found") + exit() - m3u8_link_raw = str( - search(r'\(.*?)\<\/file\>', xml_page).group( - 1)).strip().replace("&", "&") anime_name = str( search(r'\(.*?)\<\/series_title\>', xml_page) - .group(1)).strip().replace("’", "'").replace( - ":", " - ").replace("'", "'") + .group(1)).strip().replace("’", "'").replace( + ":", " - ").replace("'", "'") + logging.debug("anime_name : %s" % anime_name) + episode_number = str( search(r'\(.*?)\<\/episode_number\>', xml_page).group(1)).strip() + logging.debug("episode_number : %s" % episode_number) + width = str( search(r'\(.*?)\<\/width\>', xml_page).group( 1)).strip() + logging.debug("width : %s" % width) + height = str( search(r'\(.*?)\<\/height\>', xml_page).group( 1)).strip() + logging.debug("height : %s" % height) + # print("m3u8_link : %s\nanime_name : %s\nepisode_number : %s\nwidth : %s\nheight : %s\n" % (m3u8_link_raw, anime_name, episode_number, width, height)) # self.subFetcher(xml=str(xml_page), anime_name=anime_name, episode_number=episode_number) file_name = sub(r'[^A-Za-z0-9\ \-\' \\]+', '', str(anime_name)) + " - " + str( episode_number) + " [%sx%s].mp4" % (width, height) - # print("File Name : %s\n" % file_name) + logging.debug("file_name : %s" % file_name) + # print("File Name : %s\n" % file_name) try: MAX_PATH = int(check_output(['getconf', 'PATH_MAX', '/'])) - #print(MAX_PATH) + # print(MAX_PATH) except (Exception): MAX_PATH = 4096 @@ -154,7 +204,7 @@ class CrunchyRoll(object): makedirs("Output") if path.isfile("Output/" + file_name): - print('[Anime-dl] File Exist! Skipping ', file_name, '\n') + print('[Anime-dl] File Exist! Skipping %s\n' % file_name) pass else: self.subFetcher( @@ -162,13 +212,17 @@ class CrunchyRoll(object): anime_name=anime_name, episode_number=episode_number) # UNCOMMENT THIS LINE!!! - m3u8_file = sess.get( - url=m3u8_link_raw, cookies=cookies, - headers=headers).text.splitlines()[2] - # print("M3u8 : %s" % m3u8_file) - ffmpeg_command = "ffmpeg -i \"%s\" -c copy -bsf:a aac_adtstoasc \"%s\"" % ( - m3u8_file, file_name) - call(ffmpeg_command) + if rtmpDL == "True": + self.rtmpDump(host=hostLink, file=m3u8_link_raw, url=url, filename=file_name) + else: + m3u8_file = sess.get( + url=m3u8_link_raw, cookies=cookies, + headers=headers).text.splitlines()[2] + # print("M3u8 : %s" % m3u8_file) + ffmpeg_command = "ffmpeg -i \"%s\" -c copy -bsf:a aac_adtstoasc \"%s\"" % ( + m3u8_file, file_name) + logging.debug("ffmpeg_command : %s" % ffmpeg_command) + call(ffmpeg_command) for video_file in glob("*.mp4"): try: @@ -189,27 +243,50 @@ class CrunchyRoll(object): video_id, url) xml_page = sess.get( url=infoURL, headers=headers, cookies=cookies).text + logging.debug("xml_page : %s" % xml_page) + + try: + m3u8_link_raw = str( + search(r'\(.*?)\<\/file\>', xml_page).group( + 1)).strip().replace("&", "&") + logging.debug("m3u8_link_raw : %s" % m3u8_link_raw) + if "mp4:" in m3u8_link_raw: + rtmpDL = "True" + hostLink = str( + search(r'\(.*?)\<\/host\>', xml_page).group( + 1)).strip().replace("&", "&") + + except Exception: + print("Error Found") + exit() - m3u8_link_raw = str( - search(r'\(.*?)\<\/file\>', xml_page).group( - 1)).strip().replace("&", "&") anime_name = str( search(r'\(.*?)\<\/series_title\>', xml_page) .group(1)).strip().replace("’", "'").replace( ":", " - ").replace("'", "'") + logging.debug("anime_name : %s" % anime_name) + episode_number = str( search(r'\(.*?)\<\/episode_number\>', xml_page).group(1)).strip() + logging.debug("episode_number : %s" % episode_number) + width = str( search(r'\(.*?)\<\/width\>', xml_page).group( 1)).strip() + logging.debug("width : %s" % width) + height = str( search(r'\(.*?)\<\/height\>', xml_page).group( 1)).strip() + logging.debug("height : %s" % height) + # print("m3u8_link : %s\nanime_name : %s\nepisode_number : %s\nwidth : %s\nheight : %s\n" % (m3u8_link_raw, anime_name, episode_number, width, height)) # self.subFetcher(xml=str(xml_page), anime_name=anime_name, episode_number=episode_number) file_name = sub(r'[^A-Za-z0-9\ \-\' \\]+', '', str(anime_name)) + " - " + str( episode_number) + " [%sx%s].mp4" % (width, height) + logging.debug("file_name : %s" % file_name) + # print("File Name : %s\n" % file_name) try: MAX_PATH = int(check_output(['getconf', 'PATH_MAX', '/'])) @@ -232,13 +309,17 @@ class CrunchyRoll(object): anime_name=anime_name, episode_number=episode_number) # UNCOMMENT THIS LINE!!! - m3u8_file = sess.get( - url=m3u8_link_raw, cookies=cookies, - headers=headers).text.splitlines()[2] - # print("M3u8 : %s" % m3u8_file) - ffmpeg_command = "ffmpeg -i \"%s\" -c copy -bsf:a aac_adtstoasc \"%s\"" % ( - m3u8_file, file_name) - call(ffmpeg_command) + if rtmpDL == "True": + self.rtmpDump(host = hostLink, file = m3u8_link_raw, url = url, filename = file_name) + else: + m3u8_file = sess.get( + url=m3u8_link_raw, cookies=cookies, + headers=headers).text.splitlines()[2] + # print("M3u8 : %s" % m3u8_file) + ffmpeg_command = "ffmpeg -i \"%s\" -c copy -bsf:a aac_adtstoasc \"%s\"" % ( + m3u8_file, file_name) + logging.debug("ffmpeg_command : %s" % ffmpeg_command) + call(ffmpeg_command) for video_file in glob("*.mp4"): try: @@ -259,32 +340,54 @@ class CrunchyRoll(object): video_id, url) xml_page = sess.get( url=infoURL, headers=headers, cookies=cookies).text + logging.debug("xml_page : %s" % xml_page) + + try: + m3u8_link_raw = str( + search(r'\(.*?)\<\/file\>', xml_page).group( + 1)).strip().replace("&", "&") + logging.debug("m3u8_link_raw : %s" % m3u8_link_raw) + if "mp4:" in m3u8_link_raw: + rtmpDL = "True" + hostLink = str( + search(r'\(.*?)\<\/host\>', xml_page).group( + 1)).strip().replace("&", "&") + + except Exception: + print("Error Found") + exit() - m3u8_link_raw = str( - search(r'\(.*?)\<\/file\>', xml_page).group( - 1)).strip().replace("&", "&") anime_name = str( search(r'\(.*?)\<\/series_title\>', xml_page) - .group(1)).strip().replace("’", "'").replace( - ":", " - ").replace("'", "'") + .group(1)).strip().replace("’", "'").replace( + ":", " - ").replace("'", "'") + logging.debug("anime_name : %s" % anime_name) + episode_number = str( search(r'\(.*?)\<\/episode_number\>', xml_page).group(1)).strip() + logging.debug("episode_number : %s" % episode_number) + width = str( search(r'\(.*?)\<\/width\>', xml_page).group( 1)).strip() + logging.debug("width : %s" % width) + height = str( search(r'\(.*?)\<\/height\>', xml_page).group( 1)).strip() + logging.debug("height : %s" % height) + # print("m3u8_link : %s\nanime_name : %s\nepisode_number : %s\nwidth : %s\nheight : %s\n" % (m3u8_link_raw, anime_name, episode_number, width, height)) # self.subFetcher(xml=str(xml_page), anime_name=anime_name, episode_number=episode_number) file_name = sub(r'[^A-Za-z0-9\ \-\' \\]+', '', str(anime_name)) + " - " + str( episode_number) + " [%sx%s].mp4" % (width, height) - # print("File Name : %s\n" % file_name) + logging.debug("file_name : %s" % file_name) + # print("File Name : %s\n" % file_name) try: MAX_PATH = int(check_output(['getconf', 'PATH_MAX', '/'])) - #print(MAX_PATH) + # print(MAX_PATH) except (Exception): MAX_PATH = 4096 @@ -295,7 +398,7 @@ class CrunchyRoll(object): makedirs("Output") if path.isfile("Output/" + file_name): - print('[Anime-dl] File Exist! Skipping ', file_name, '\n') + print('[Anime-dl] File Exist! Skipping %s\n' % file_name) pass else: self.subFetcher( @@ -303,13 +406,17 @@ class CrunchyRoll(object): anime_name=anime_name, episode_number=episode_number) # UNCOMMENT THIS LINE!!! - m3u8_file = sess.get( - url=m3u8_link_raw, cookies=cookies, - headers=headers).text.splitlines()[2] - # print("M3u8 : %s" % m3u8_file) - ffmpeg_command = "ffmpeg -i \"%s\" -c copy -bsf:a aac_adtstoasc \"%s\"" % ( - m3u8_file, file_name) - call(ffmpeg_command) + if rtmpDL == "True": + self.rtmpDump(host=hostLink, file=m3u8_link_raw, url=url, filename=file_name) + else: + m3u8_file = sess.get( + url=m3u8_link_raw, cookies=cookies, + headers=headers).text.splitlines()[2] + # print("M3u8 : %s" % m3u8_file) + ffmpeg_command = "ffmpeg -i \"%s\" -c copy -bsf:a aac_adtstoasc \"%s\"" % ( + m3u8_file, file_name) + logging.debug("ffmpeg_command : %s" % ffmpeg_command) + call(ffmpeg_command) for video_file in glob("*.mp4"): try: @@ -330,32 +437,54 @@ class CrunchyRoll(object): video_id, url) xml_page = sess.get( url=infoURL, headers=headers, cookies=cookies).text + logging.debug("xml_page : %s" % xml_page) + + try: + m3u8_link_raw = str( + search(r'\(.*?)\<\/file\>', xml_page).group( + 1)).strip().replace("&", "&") + logging.debug("m3u8_link_raw : %s" % m3u8_link_raw) + if "mp4:" in m3u8_link_raw: + rtmpDL = "True" + hostLink = str( + search(r'\(.*?)\<\/host\>', xml_page).group( + 1)).strip().replace("&", "&") + + except Exception: + print("Error Found") + exit() - m3u8_link_raw = str( - search(r'\(.*?)\<\/file\>', xml_page).group( - 1)).strip().replace("&", "&") anime_name = str( search(r'\(.*?)\<\/series_title\>', xml_page) - .group(1)).strip().replace("’", "'").replace( - ":", " - ").replace("'", "'") + .group(1)).strip().replace("’", "'").replace( + ":", " - ").replace("'", "'") + logging.debug("anime_name : %s" % anime_name) + episode_number = str( search(r'\(.*?)\<\/episode_number\>', xml_page).group(1)).strip() + logging.debug("episode_number : %s" % episode_number) + width = str( search(r'\(.*?)\<\/width\>', xml_page).group( 1)).strip() + logging.debug("width : %s" % width) + height = str( search(r'\(.*?)\<\/height\>', xml_page).group( 1)).strip() + logging.debug("height : %s" % height) + # print("m3u8_link : %s\nanime_name : %s\nepisode_number : %s\nwidth : %s\nheight : %s\n" % (m3u8_link_raw, anime_name, episode_number, width, height)) # self.subFetcher(xml=str(xml_page), anime_name=anime_name, episode_number=episode_number) file_name = sub(r'[^A-Za-z0-9\ \-\' \\]+', '', str(anime_name)) + " - " + str( episode_number) + " [%sx%s].mp4" % (width, height) - # print("File Name : %s\n" % file_name) + logging.debug("file_name : %s" % file_name) + # print("File Name : %s\n" % file_name) try: MAX_PATH = int(check_output(['getconf', 'PATH_MAX', '/'])) - #print(MAX_PATH) + # print(MAX_PATH) except (Exception): MAX_PATH = 4096 @@ -366,7 +495,7 @@ class CrunchyRoll(object): makedirs("Output") if path.isfile("Output/" + file_name): - print('[Anime-dl] File Exist! Skipping ', file_name, '\n') + print('[Anime-dl] File Exist! Skipping %s\n' % file_name) pass else: self.subFetcher( @@ -374,13 +503,17 @@ class CrunchyRoll(object): anime_name=anime_name, episode_number=episode_number) # UNCOMMENT THIS LINE!!! - m3u8_file = sess.get( - url=m3u8_link_raw, cookies=cookies, - headers=headers).text.splitlines()[2] - # print("M3u8 : %s" % m3u8_file) - ffmpeg_command = "ffmpeg -i \"%s\" -c copy -bsf:a aac_adtstoasc \"%s\"" % ( - m3u8_file, file_name) - call(ffmpeg_command) + if rtmpDL == "True": + self.rtmpDump(host=hostLink, file=m3u8_link_raw, url=url, filename=file_name) + else: + m3u8_file = sess.get( + url=m3u8_link_raw, cookies=cookies, + headers=headers).text.splitlines()[2] + # print("M3u8 : %s" % m3u8_file) + ffmpeg_command = "ffmpeg -i \"%s\" -c copy -bsf:a aac_adtstoasc \"%s\"" % ( + m3u8_file, file_name) + logging.debug("ffmpeg_command : %s" % ffmpeg_command) + call(ffmpeg_command) for video_file in glob("*.mp4"): try: @@ -472,6 +605,7 @@ class CrunchyRoll(object): r'subtitle_script_id\=(.*?)\'\ title\=\'\[(.*?)\]\ (.*?)\'', str(xml)): # print("Sub ID : %s\t| Sub Lang : %s" % (sub_id, sub_lang)) + logging.debug("sub_id : %s\nsub_lang : %s\nsub_lang2 : %s" % (sub_id, sub_lang, sub_lang2)) xml_return = str( sess.get( url="http://www.crunchyroll.com/xml/?req=RpcApiSubtitle_GetXml&subtitle_script_id=%s" @@ -480,9 +614,11 @@ class CrunchyRoll(object): # print(xml_return) iv = str( search(r'\(.*?)\<\/iv\>', xml_return).group(1)).strip() + logging.debug("iv : %s" % iv) data = str( search(r'\(.*?)\<\/data\>', xml_return).group( 1)).strip() + logging.debug("data : %s" % data) # print("Sub ID : %s\t| iv : %s\t| data : %s" % (sub_id, iv, data)) subtitle = self._decrypt_subtitles(data, iv, sub_id).decode('utf-8') @@ -493,6 +629,7 @@ class CrunchyRoll(object): lang_code = str( search(r'lang_code\=\"(.*?)\"', str(subtitle)).group( 1)).strip() + logging.debug("lang_code : %s" % lang_code) sub_file_name = sub(r'[^A-Za-z0-9\ \-\' \\]+', '', str(anime_name)) + " - " + str( episode_number) + ".%s.ass" % lang_code diff --git a/anime_dl/version.py b/anime_dl/version.py index 7cf827c..1f33af3 100644 --- a/anime_dl/version.py +++ b/anime_dl/version.py @@ -1,2 +1,2 @@ # Format : YY/MM/DD -__version__ = "2017.04.13" +__version__ = "2017.04.17" diff --git a/docs/Changelog.md b/docs/Changelog.md index ed9c9db..78cc5a0 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -7,4 +7,6 @@ - Support for Whole Show Downloading for Crunchyroll [2017.03.06] - Selection of language for the Crunchyroll Show [2017.03.06] - Downloading only subtitles (skip video downloads) [2017.04.13] -- Fix for [6](https://github.com/Xonshiz/anime-dl/issues/6) and Fix for [3](https://github.com/Xonshiz/anime-dl/issues/3) [2017.04.13] \ No newline at end of file +- Fix for [6](https://github.com/Xonshiz/anime-dl/issues/6) and Fix for [3](https://github.com/Xonshiz/anime-dl/issues/3) [2017.04.13] +- Fix for #9 [2017.04.13] +- Added `Verbose Logging` [2017.04.13] \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index f25cd5a..7f97591 100644 --- a/docs/index.md +++ b/docs/index.md @@ -31,11 +31,13 @@ Anime-dl is a Command-line program to download anime from CrunchyRoll and Funima You can check the list of supported websites [**`HERE`**](https://github.com/Xonshiz/anime-dl/blob/master/Supported_Sites.md). ## Dependencies Installation -This script can run on multiple Operating Systems. But, the script depends on some external binaries or libs. We need `FFmpeg` and `Node.js` in our paths. +This script can run on multiple Operating Systems. But, the script depends on some external binaries or libs. We need `FFmpeg` and `Node.js` in our paths. There are some old streams on Crunchyroll which only support `rtmpe` streams, as noted from Issue #9. For this, you need `rtmpdump`. + +**`These dependencies are required on ALL the operating systems, ALL!.`** 1.) Make sure you have Python installed and is present in your system's path. -2.) Grab [FFmpeg from this link](https://ffmpeg.org/download.html) and [Node.js from this link](https://nodejs.org/en/download/). +2.) Grab [FFmpeg from this link](https://ffmpeg.org/download.html), [Node.js from this link](https://nodejs.org/en/download/) and [RTMPDump](https://www.videohelp.com/software/RTMPDump). 3.) Install FFmpeg and Node.js and place it in the directory of this script, or put them in your system's path. @@ -83,6 +85,7 @@ Currently, the script supports these arguments : -p,--password Indicates password for a website. [REQUIRED] -r,--resolution Indicates the desired resolution. (default = 720p) --skip Skip video downloads (Will only download subtitles) +-v,--verbose Starts Verbose Logging for detailed information. -l,--language Selects the language for the show. (default = Japanese) [Langs = english, dub, sub, Japanese, eng] ``` @@ -130,6 +133,7 @@ This is a very basic and small sript, so at the moment it only have a few featur * Skip if the file has already been downloaded. * Downloads all the episodes for a show available on Crunchyroll. * Gives choice for downloading subs or dubs of a series available on Crunchyroll. +* Choice to download only the subs and skip the videos. ## Changelog You can check the changelog [**`HERE`**](https://github.com/Xonshiz/anime-dl/blob/master/Changelog.md). @@ -138,7 +142,9 @@ You can check the changelog [**`HERE`**](https://github.com/Xonshiz/anime-dl/blo If your're planning to open an issue for the script or ask for a new feature or anything that requires opening an Issue, then please do keep these things in mind. ### Reporting Issues -PLEASE RUN THIS SCRIPT IN A COMMAND LINE (as mentioned in the Usage section) AND DON'T SAY THAT `THE SCRIPT CLOSED TOO QUICK, I COULDN'T SEE`. +PLEASE RUN THIS SCRIPT IN A COMMAND LINE (as mentioned in the Usage section) AND DON'T SAY THAT `THE SCRIPT CLOSED TOO QUICK, I COULDN'T SEE`. If something doesn't work like it's supposed to, run the command with the `--verbose` argument. It'll create a `Error Log.txt` file in the same directory. Upload the content of that file on Github Gists/Pastebin etc. and share that link. + +**Please make sure that you remove your loggin credentials from the Error Log.txt file before you post its contents anywhere.** If you're here to report an issue, please follow the basic syntax to post a request : @@ -146,6 +152,8 @@ If you're here to report an issue, please follow the basic syntax to post a requ **Command Line Arguments You Gave** : The whole command that you gave to execute/run this script. +**Verbose Log Link** : Link to the Gist/Pastebin that holds the content of Error Log.txt. + **Long Explanation** : Describe in details what you saw, what should've happened and what actually happened. This should be enough, but it'll be great if you can add more ;)