-
-
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.
- Loading branch information
0 parents
commit 26d9f8c
Showing
16 changed files
with
591 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[bumpversion] | ||
current_version = 0.1 | ||
commit = True | ||
tag = False | ||
parse = ^ | ||
(?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+) | ||
((?P<pre>a|b|rc) | ||
)? | ||
serialize = | ||
{major}.{minor}.{patch}{pre} | ||
{major}.{minor}.{patch} | ||
|
||
[bumpversion:part:pre] | ||
optional_value = _ | ||
values = | ||
_ | ||
a | ||
b | ||
rc | ||
|
||
[bumpversion:file:setup.py] | ||
|
||
[bumpversion:file:fichub_cli/cli.py] | ||
search = typer.echo("fichub-cli-metadata: v{current_version}") | ||
replace = typer.echo("fichub-cli-metadata: v{new_version}") | ||
|
||
[bumpversion:file:fichub_cli/utils/fichub.py] | ||
search = 'User-Agent': 'fichub_cli_metadata/{current_version}' | ||
replace = 'User-Agent': 'fichub_cli_metadata/{new_version}' | ||
|
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 |
---|---|---|
@@ -0,0 +1,146 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# ebooks | ||
*.epub | ||
|
||
# C extensions | ||
*.so | ||
|
||
#vscode | ||
.vscode/* | ||
.vscode/settings.json | ||
.vscode/tasks.json | ||
.vscode/launch.json | ||
.vscode/extensions.json | ||
*.code-workspace | ||
|
||
# Local History for Visual Studio Code | ||
.history/ | ||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
pip-wheel-metadata/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# extras | ||
urls.* | ||
urls |
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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Arbaaz Laskar | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<h1 align="center">fichub-cli-metadata</h1> | ||
|
||
A metadata plugin for fetching Metadata from the Fichub API for [fichub-cli](https://github.com/FicHub/fichub-cli/)<br><br> | ||
|
||
To report issues upstream for the supported sites, visit https://fichub.net/#contact<br> | ||
|
||
To report issues for the plugin, open an issue at https://github.com/fichub-cli-contrib/fichub-cli-metadata/issues<br> | ||
|
||
To report issues for the CLI, open an issue at https://github.com/FicHub/fichub-cli/issues<br> | ||
|
||
# Installation | ||
|
||
## Using pip (Recommended) | ||
|
||
``` | ||
pip install -U fichub-cli-metadata | ||
``` | ||
|
||
## From Source (Might have bugs, for testing only) | ||
|
||
``` | ||
pip install git+https://github.com/fichub-cli-contrib/fichub-cli-metadata@main | ||
``` | ||
|
||
# Usage | ||
|
||
``` | ||
> fichub_cli metadata | ||
Usage: fichub_cli metadata [OPTIONS] COMMAND [ARGS]... | ||
A metadata plugin for fetching Metadata from the Fichub API for the fichub-cli | ||
Options: | ||
-i, --input TEXT Input: Either an URL or path to a file | ||
-o, --out-dir TEXT Path to the Output directory for files (default: Current Directory) | ||
-d, --debug Show the log in the console for debugging | ||
--log / --no-log Save the logfile for debugging [default: no-log] | ||
--version / --no-version Display version & quit [default: no-version] | ||
--help Show this message and exit. | ||
``` | ||
|
||
### Default Configuration | ||
|
||
- The fanfiction will be downloaded in the current directory. To change it, use `-o` followed by the path to the directory. | ||
- Failed downloads will be saved in the `err.log` file in the current directory. | ||
|
||
Check `fichub_cli metadata --help` for more info. | ||
|
||
## Example | ||
|
||
- To fetch metadata using an URL | ||
|
||
``` | ||
fichub_cli metadata -i https://archiveofourown.org/works/10916730/chapters/24276864 | ||
``` | ||
|
||
- To fetch metadata using a file containing URLs | ||
|
||
``` | ||
fichub_cli metadata -i urls.txt | ||
``` | ||
|
||
- To choose a output directory | ||
|
||
``` | ||
fichub_cli metadata -i urls.txt -o "~/Desktop/books" | ||
``` | ||
|
||
# Links | ||
|
||
- [Fichub-cli](https://github.com/FicHub/fichub-cli/) | ||
- [Official Discord Server](https://discord.gg/sByBAhX) |
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from .cli import app |
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import typer | ||
import sys | ||
from loguru import logger | ||
from datetime import datetime | ||
from colorama import init, Fore, Style | ||
|
||
from .utils.fetch_data import FetchData | ||
|
||
init(autoreset=True) # colorama init | ||
timestamp = datetime.now().strftime("%Y-%m-%d T%H%M%S") | ||
|
||
app = typer.Typer(add_completion=False) | ||
|
||
|
||
# @logger.catch # for internal debugging | ||
@app.callback(no_args_is_help=True, | ||
invoke_without_command=True, | ||
help='A metadata plugin for fetching Metadata from the Fichub API for the fichub-cli') | ||
def metadata( | ||
input: str = typer.Option( | ||
"", "-i", "--input", help="Input: Either an URL or path to a file"), | ||
|
||
out_dir: str = typer.Option( | ||
"", "-o", " --out-dir", help="Path to the Output directory for files (default: Current Directory)"), | ||
|
||
debug: bool = typer.Option( | ||
False, "-d", " --debug", help="Show the log in the console for debugging", is_flag=True), | ||
|
||
log: bool = typer.Option( | ||
False, help="Save the logfile for debugging", is_flag=True), | ||
|
||
automated: bool = typer.Option( | ||
False, "-a", "--automated", help="For internal testing only", is_flag=True, hidden=True), | ||
|
||
version: bool = typer.Option( | ||
False, help="Display version & quit", is_flag=True) | ||
|
||
|
||
): | ||
if log: | ||
debug = True | ||
typer.echo( | ||
Fore.GREEN + f"Creating fichub_cli - {timestamp}.log in the current directory" + Style.RESET_ALL) | ||
logger.add(f"fichub_cli - {timestamp}.log") | ||
|
||
if input: | ||
fic = FetchData(debug=debug, automated=automated, | ||
out_dir=out_dir) | ||
fic.get_metadata(input) | ||
|
||
if version: | ||
typer.echo("fichub-cli-metadata: v0.1") | ||
|
||
try: | ||
if fic.exit_status == 1: | ||
typer.echo(Fore.RED + """ | ||
Unsupported URLs found! Check err.log in the current directory!""" + Style.RESET_ALL) | ||
sys.exit(fic.exit_status) | ||
except UnboundLocalError: | ||
sys.exit(0) |
Empty file.
Oops, something went wrong.