forked from PeskyPotato/archive-chan
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add typed-argument-parser to requirements.txt
- Loading branch information
AutoPR
committed
May 2, 2023
1 parent
7a647af
commit 491db4f
Showing
2 changed files
with
19 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,7 @@ Flask | |
requests | ||
SuperJson | ||
Toolz | ||
requests | ||
SuperJson | ||
Toolz | ||
typed-argument-parser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,20 @@ | ||
from argparse import ArgumentParser | ||
from tap import Tap | ||
from pathlib import Path | ||
|
||
class Args(Tap): | ||
thread: str # Link to the 4chan thread or the name of the board. | ||
archived: bool = False # Download threads from the /board/archive/ as well. | ||
archived_only: bool = False # Download threads from the /board/archive/ INSTEAD. | ||
preserve_media: bool = False # Save images and video files locally. | ||
path: Path = Path("./threads/") # Path to folder where the threads should be saved. | ||
posts: int = None # Number of posts to download. | ||
retries: int = 1 # Retry -r times if a download fails. | ||
skip_renders: bool = False # Do not render thread HTMLs after downloading them. | ||
text_only: bool = False # Download only HTMLs or JSONs. | ||
use_db: bool = False # Stores threads into a database, this is experimental. | ||
verbose: bool = False # Verbose logging to stdout. | ||
|
||
def get_args(): | ||
"""Get user input from the command-line and parse it.""" | ||
parser = ArgumentParser(description="Archives 4chan threads") | ||
parser.add_argument( | ||
"thread", help="Link to the 4chan thread or the name of the board." | ||
) | ||
parser.add_argument( | ||
"-a", | ||
"--archived", | ||
action="store_true", | ||
help="Download threads from the /board/archive/ as well.", | ||
) | ||
parser.add_argument( | ||
"-ao", | ||
"--archived_only", | ||
action="store_true", | ||
help="Download threads from the /board/archive/ INSTEAD.", | ||
) | ||
parser.add_argument( | ||
"-p", | ||
"--preserve_media", | ||
action="store_true", | ||
help="Save images and video files locally.", | ||
) | ||
parser.add_argument( | ||
"--path", | ||
default="./threads/", | ||
help="Path to folder where the threads should be saved.", | ||
type=Path, | ||
) | ||
parser.add_argument( | ||
"--posts", | ||
default=None, | ||
help="Number of posts to download", | ||
type=int, | ||
) | ||
parser.add_argument( | ||
"-r", | ||
"--retries", | ||
default=1, | ||
help="Retry -r times if a download fails.", | ||
type=int, | ||
) | ||
parser.add_argument( | ||
"--skip_renders", | ||
action="store_true", | ||
help="Do not render thread HTMLs after downloading them.", | ||
) | ||
parser.add_argument( | ||
"--text_only", | ||
action="store_true", | ||
help="Download only HTMLs or JSONs.", | ||
) | ||
parser.add_argument( | ||
"--use_db", | ||
action="store_true", | ||
help="Stores threads into a database, this is experimental.", | ||
) | ||
parser.add_argument( | ||
"-v", | ||
"--verbose", | ||
action="store_true", | ||
help="Verbose logging to stdout.", | ||
) | ||
args = parser.parse_args() | ||
return args | ||
args = Args().parse_args() | ||
return args |