Skip to content

Commit

Permalink
- Removed CLI capability
Browse files Browse the repository at this point in the history
- Renamed Anime_Downloader.py to downloader.py and moved to util package
- Removed Anime_Scraper.py
- Code reformatted as for standards (fixing codacy issues)

TODO:
- Check all the website supports after the code reformatiing
- Add docstrings
  • Loading branch information
Oshan96 committed May 8, 2020
1 parent 947c40d commit 4ee3c33
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 434 deletions.
36 changes: 16 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ You can now bulk download your favourite anime episodes for various websites, in
If this project is helpful to you and love my work and feel like showing love/appreciation, would you like to buy me a coffee?<br>
<a href="https://buymeacoff.ee/Oshan96" target="_blank"><img src="https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png" alt="Buy Me A Coffee" style="height: 41px !important;width: 174px !important;box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 3px 2px 0px rgba(190, 190, 190, 0.5) !important;" ></a>

## Important Notes:
## Important Notes
- Monkey-DL will use your browser cookies for some URLs (for the given anime website domain) if it fails to bypass cloudflare automatically.
So make sure that you visit the given URL manually from either Google Chrome or Firefox browser and let cloudflare challenge to be solved via browser.
Then Monkey-DL will use those cookies once to bypass cloudflare (Note that this is only for several websites which are using cloudflare, and also no other cookies will be read by Monkey-DL other than of that particular domain)
Expand All @@ -20,24 +20,20 @@ This is a false positive and need not to be worried. Also, if in doubt, it is ad
- The only place where the Monkey-DL releases are available is through the [releases](https://github.com/Oshan96/monkey-dl/releases) section of the repository and it is advised to avoid downloading from other places than that.

## Features
* Download Anime from various [supported websites](#Supported-Websites)
* Batch download episodes in the given range at once
* High speed downloads
* Download multiple episodes at once
* Select the resolution (from the available resolutions for the website)
* Select sub/dub (Check whether the website supports selective sub/dub downloads from [here](#Supported-Websites))
* Choose whether filler episodes need to be downloaded or not by selecting "Download fillers" (By providing animefillerlist URL)
* Name the files in "Episode - {episode_number} - {episode_title}" format by providing animefillerlist URL
* Choose the directory files need to be downloaded into
* Custom HLSDownloader to download from streams when direct download links cannot be found
* Custom decryptors for encrypted websites
- Download Anime from various [supported websites](#Supported-Websites)
- Batch download episodes in the given range at once
- High speed downloads
- Download multiple episodes at once
- Select the resolution (from the available resolutions for the website)
- Select sub/dub (Check whether the website supports selective sub/dub downloads from [here](#Supported-Websites))
- Choose whether filler episodes need to be downloaded or not by selecting "Download fillers" (By providing animefillerlist URL)
- Name the files in "Episode - {episode_number} - {episode_title}" format by providing animefillerlist URL
- Choose the directory files need to be downloaded into
- Custom HLSDownloader to download from streams when direct download links cannot be found
- Custom decryptors for encrypted websites

## Supported Websites

#### Note
FFMPEG is no longer needed (since calling FFMPEG using subprocess calls to run FFMPEG make monkey-dl detected as trojan by some antivirus).
Only custom HLS downloader will be used hereafter (v2.0.0 upwards)

| Website |Sub/Dub selection | Need recaptcha token? | Supported resolutions | File Size | Additional Notes |
|--- |--- |--- |--- |--- |--- |
| [9Anime](https://9anime.to/) | No | Yes | Default only | 500-600MB | Will always work, provided token |
Expand All @@ -53,7 +49,7 @@ Only custom HLS downloader will be used hereafter (v2.0.0 upwards)
## Download Anime Downloader [Windows]
> Note : Currently only windows executable is provided (Linux, Mac users go to [Build from source](#Building-from-source))
Download the [Latest Release](https://github.com/Oshan96/Anime-Downloader/releases) from here and extract the zip file
Download the [Latest Release](https://github.com/Oshan96/monkey-dl/releases) from here and extract the zip file

## Downloading Your Favourite Anime

Expand All @@ -79,10 +75,10 @@ It is same as the CLI version, but provided a graphical user interface to collec

Note : After v1.0.4 and anove, Anime Downloader was named as "Monkey-DL" and the executable is called "monkey-dl.exe"

* v1.0.4 and above:
- v1.0.4 and above:
Execute the "monkey-dl.exe" to start.

* v1.0.3 and lower:
- v1.0.3 and lower:
Execute the "anime-dl.exe" to start.

If you're running from source files, execute the "anime-dl.py" script
Expand Down Expand Up @@ -307,7 +303,7 @@ python3 ./Anime_Downloader -u https://9anime.to/watch/one-piece.ov8/169lyx -s 13

## Authors

* **Oshan Mendis** - *Author* - [Oshan96](https://github.com/Oshan96)
- **Oshan Mendis** - *Author* - [Oshan96](https://github.com/Oshan96)

## License

Expand Down
3 changes: 1 addition & 2 deletions monkey_dl/extractors/kwik_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ def set_direct_link(self, episode):
try:
episode.download_url = resp_headers.headers["location"]
# print(resp_headers.headers["location"])
except Exception as ex:
except Exception:
# print(resp_headers)
# printer("ERROR", ex, self.gui)
self.token = None
printer("ERROR", "Failed to retrieve direct url for " + episode.title, self.gui)
return False
Expand Down
4 changes: 2 additions & 2 deletions monkey_dl/gui/GUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import PySimpleGUI as sg
from threading import Thread
from time import sleep
from Anime_Downloader import Downloader
from util.downloader import Downloader
from util.Color import printer
from util.name_collector import EpisodeNamesCollector
from scrapers.fouranime.fouranime_scraper import FourAnimeScraper
Expand Down Expand Up @@ -35,7 +35,7 @@ def download(anime_url, names_url, start_epi, end_epi, is_filler, is_titles, tok
with open("settings.json") as (json_file):
data = json.load(json_file)
api_key = data["api_key"]
except:
except Exception:
api_key = ""

if api_key != "" and api_key != "insert_2captcha_api_key":
Expand Down
8 changes: 0 additions & 8 deletions monkey_dl/monkey-dl.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import os
import sys
import warnings
from queue import Queue
from gui.GUI import AnimeGUI

if __name__ == "__main__":
warnings.filterwarnings("ignore")
# activate color codes
if sys.platform.lower() == "win32":
os.system("color")

AnimeGUI(Queue()).run()
6 changes: 3 additions & 3 deletions monkey_dl/scrapers/animeflix/animeflix_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def __collect_episodes(self):
continue

title = epi["title"]
id = epi["id"]
epi_id = epi["id"]
episode = Episode(title, "Episode - {epi}".format(epi=str(epi_no)))
episode.id = id
episode.id = epi_id

self.__set_download_link(episode)

Expand All @@ -99,7 +99,7 @@ def get_direct_links(self):
try:
episodes = self.__collect_episodes()
return episodes
except Exception as ex:
except Exception:
trace = traceback.format_exc()
print(trace)
return None
2 changes: 1 addition & 1 deletion monkey_dl/scrapers/animepahe/animepahe_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __set_kwik_links(self):
if self.resolution == "1080":
link = api_data[links[1]]["1080"]["url"]
id = link.split("/")[-1]
except Exception as ex:
except Exception:
printer("ERROR", "1080p not available!", self.gui)
printer("INFO", "Continuing with 720p link...", self.gui)

Expand Down
2 changes: 1 addition & 1 deletion monkey_dl/scrapers/animetake/animetake_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __set_episode_direct_link(self, episode):

try:
link = self.__get_direct_link(epi_sources_url)
except:
except Exception:
return False

if link is not None:
Expand Down
6 changes: 3 additions & 3 deletions monkey_dl/scrapers/animeultima/animeultima_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from scrapers.base_scraper import BaseScraper
from util.Episode import Episode
from extractors.jwplayer_extractor import JWPlayerExtractor
from util.js_unpacker import JsUnpacker
from util.js_unpacker import eval


class AnimeUltimaScraper(BaseScraper):
Expand Down Expand Up @@ -84,7 +84,7 @@ def set_stream_url(self, episode):
def set_direct_url(self, episode, page_url):
page = self.session.get(page_url).text
func = re.search("eval\(.*\)", page).group(0)
eval_data = JsUnpacker().eval(func)
eval_data = eval(func)
link = re.search('fone\s+=\s+\"(.*)\"', eval_data).group(1)
# print(link)
episode.download_url = link
Expand Down Expand Up @@ -157,7 +157,7 @@ def get_direct_links(self):
self.collect_episodes(anime_id, start_page, end_page)

return self.episodes
except Exception as ex:
except Exception:
trace = traceback.format_exc()
print(trace)
return None
Expand Down
2 changes: 1 addition & 1 deletion monkey_dl/scrapers/base_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_url_content(self):
try:
page = self.session.get(self.url).content
return page
except CloudflareException as ex:
except CloudflareException:
print(
"Cloudflare exception raised! browser cookies will be used in retry. Make sure you visited the given url from chrome/firefox")
printer("ERROR", "Cloudflare exception raised!", self.gui)
Expand Down
13 changes: 7 additions & 6 deletions monkey_dl/scrapers/fouranime/fouranime_scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
from util.js_unpacker import JsUnpacker


def get_packed(page):
pack_links = [match.group(0) for match in re.finditer("eval\(.*\)", page)]
return pack_links


class FourAnimeScraper(BaseScraper):
def __init__(self, url, start_episode, end_episode, session, gui=None):
super().__init__(url, start_episode, end_episode, session, gui)
Expand Down Expand Up @@ -46,10 +51,6 @@ def __extract_page_urls(self):

return self.episodes

def __get_packed(self, page):
pack_links = [match.group(0) for match in re.finditer("eval\(.*\)", page)]
return pack_links

def __extract_download_urls(self):
Color.printer("INFO", "Extracting download URLs...", self.gui)
success = True
Expand All @@ -76,7 +77,7 @@ def __extract_download_urls(self):

if video_tag is None or video_tag["src"] == '':
print("checking for packed data")
packed_funcs = self.__get_packed(page.decode('utf-8'))
packed_funcs = get_packed(page.decode('utf-8'))
# print(packed_funcs)

if len(packed_funcs) > 0:
Expand All @@ -91,7 +92,7 @@ def __extract_download_urls(self):
episode.download_url = src
success = True
continue
except:
except Exception:
Color.printer("ERROR", "Download link not found for " + episode.episode, self.gui)
success = False
else:
Expand Down
Loading

0 comments on commit 4ee3c33

Please sign in to comment.