Skip to content

Commit

Permalink
Fix for #12 and code optimization
Browse files Browse the repository at this point in the history
Read the changelog for more information.
  • Loading branch information
Xonshiz committed May 30, 2017
1 parent b31f218 commit e01cae7
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 373 deletions.
4 changes: 3 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@
- 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]
- Fix for #11 [2017.04.21]
- Fix for #11 [2017.04.21]
- Re-write code to remove unnecessary parts [2017.05.30]
- Fix for #12 [2017.05.30]
16 changes: 15 additions & 1 deletion anime_dl/AnimeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
from sys import exit


'''First, the honcho returns the website name and after that, the corresponding methods are called for a particular
website. I don't remember why I added an extra step, I really don't. Oh well, it's working, so let it work.'''

class AnimeDL(object):

def __init__(self, url, username, password, resolution, language, skipper, logger):
Expand All @@ -26,15 +29,26 @@ def __init__(self, url, username, password, resolution, language, skipper, logge
sites.crunchyroll.CrunchyRoll(
url=url[0], password=password, username=username, resolution=resolution, language=language, skipper=skipper, logger = logger)

elif website == "Funimation":
if not url[0] or not username[0] or not password[0]:
print("Please enter the required arguments. Run __main__.py --help")
exit()
else:
sites.funimation.Funimation(url[0], username, password, resolution, language)

def honcho(self, url):
# print("Got url : %s" % url)
# Verify that we have a sane url and return which website it belongs
# to.

# if there's not http:/, then netloc is empty.
# Gotta add the "if crunchyroll in url..."
# print(url)
domain = urlparse(url).netloc
# print(domain)

if domain in ["www.funimation.com", "funimation.com"]:
sites.funimation.Funimation()
return "Funimation"

elif domain in ["www.crunchyroll.com", "crunchyroll.com"]:
return "Crunchyroll"
1 change: 1 addition & 0 deletions anime_dl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
# from anime_dl import AnimeDL
from sys import exit
from version import __version__
from anime_dl import animeName
import argparse
import logging
import platform
Expand Down
19 changes: 19 additions & 0 deletions anime_dl/animeName.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import re
import subprocess

class animeName(object):

def nameEdit(self, animeName, episodeNumber, resolution):
rawName = str(animeName).title().strip().replace("Season ", "S") + " - " + str(episodeNumber).strip() + " [" + str(resolution) + "]"
fileName = str(re.sub(r'[^A-Za-z0-9\ \-\' \\]+', '', str(animeName))).title().strip().replace("Season ", "S") + " - " + str(episodeNumber).strip() + " [" + str(resolution) + "].mp4"

try:
MAX_PATH = int(subprocess.check_output(['getconf', 'PATH_MAX', '/']))
# print(MAX_PATH)
except (Exception):
MAX_PATH = 4096

if len(fileName) > MAX_PATH:
file_name = fileName[:MAX_PATH]

return fileName
Loading

0 comments on commit e01cae7

Please sign in to comment.