move code from placeholder script to input.py
This commit is contained in:
parent
b0fb8d4860
commit
d9fe6a4b32
3 changed files with 55 additions and 51 deletions
50
manga-dlp.py
50
manga-dlp.py
|
@ -1,52 +1,6 @@
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
from mangadlp.input import get_args
|
||||
from mangadlp.input import main
|
||||
|
||||
MDLP_VERSION = "2.1.6"
|
||||
|
||||
|
||||
def get_input():
|
||||
print(f"manga-dlp version: {MDLP_VERSION}")
|
||||
print("Enter details of the manga you want to download:")
|
||||
while True:
|
||||
try:
|
||||
url_uuid = str(input("Url or UUID: "))
|
||||
readlist = str(input("List with links (optional): "))
|
||||
language = str(input("Language: ")) or "en"
|
||||
list_chapters = str(input("List chapters? y/N: "))
|
||||
if list_chapters.lower() != "y" or list_chapters.lower() != "yes":
|
||||
chapters = str(input("Chapters: "))
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
except:
|
||||
continue
|
||||
else:
|
||||
break
|
||||
|
||||
args = [
|
||||
"python3",
|
||||
"manga-dlp.py",
|
||||
"-l",
|
||||
language,
|
||||
"-c",
|
||||
chapters,
|
||||
]
|
||||
if url_uuid:
|
||||
args.append("-u")
|
||||
args.append(url_uuid)
|
||||
if readlist:
|
||||
args.append("--read")
|
||||
args.append(readlist)
|
||||
if list_chapters.lower() == "y" or list_chapters.lower() == "yes":
|
||||
args.append("--list")
|
||||
|
||||
# start script again with the arguments
|
||||
subprocess.call(args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1:
|
||||
get_args()
|
||||
else:
|
||||
get_input()
|
||||
main()
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import mangadlp.input
|
||||
import sys
|
||||
|
||||
mangadlp.input.get_args()
|
||||
from mangadlp.input import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
@ -52,6 +53,45 @@ def call_app(args):
|
|||
mdlp.get_manga()
|
||||
|
||||
|
||||
def get_input():
|
||||
print(f"manga-dlp version: {MDLP_VERSION}")
|
||||
print("Enter details of the manga you want to download:")
|
||||
while True:
|
||||
try:
|
||||
url_uuid = str(input("Url or UUID: "))
|
||||
readlist = str(input("List with links (optional): "))
|
||||
language = str(input("Language: ")) or "en"
|
||||
list_chapters = str(input("List chapters? y/N: "))
|
||||
if list_chapters.lower() != "y" or list_chapters.lower() != "yes":
|
||||
chapters = str(input("Chapters: "))
|
||||
except KeyboardInterrupt:
|
||||
sys.exit(1)
|
||||
except:
|
||||
continue
|
||||
else:
|
||||
break
|
||||
|
||||
args = [
|
||||
"python3",
|
||||
"manga-dlp.py",
|
||||
"-l",
|
||||
language,
|
||||
"-c",
|
||||
chapters,
|
||||
]
|
||||
if url_uuid:
|
||||
args.append("-u")
|
||||
args.append(url_uuid)
|
||||
if readlist:
|
||||
args.append("--read")
|
||||
args.append(readlist)
|
||||
if list_chapters.lower() == "y" or list_chapters.lower() == "yes":
|
||||
args.append("--list")
|
||||
|
||||
# start script again with the arguments
|
||||
subprocess.call(args)
|
||||
|
||||
|
||||
def get_args():
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Script to download mangas from various sites"
|
||||
|
@ -151,5 +191,12 @@ def get_args():
|
|||
check_args(args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
if len(sys.argv) > 1:
|
||||
get_args()
|
||||
else:
|
||||
get_input()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Reference in a new issue