Skip to content

Commit

Permalink
- Implemented command line interface
Browse files Browse the repository at this point in the history
  • Loading branch information
EchterAlsFake committed Apr 4, 2024
1 parent 676aeaa commit 42f3b42
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ for video in videos:
# SEE DOCUMENTATION FOR MORE
```

> [!NOTE]
> XVideos API can also be used from the command line. Do: xvideos_api -h to see the options
# Changelog
See [Changelog](https://github.com/EchterAlsFake/hqporner_api/blob/master/README/Changelog.md) for more details.

Expand Down
33 changes: 33 additions & 0 deletions hqporner_api/api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import argparse

from functools import cached_property
from random import choice
from typing import Generator
Expand Down Expand Up @@ -344,3 +346,34 @@ def get_brazzers_videos(cls, pages=5) -> Generator[Video, None, None]:
urls = PATTERN_VIDEOS_ON_SITE.findall(html_content)
for url_ in urls:
yield Video(f"{root_url}hdporn/{url_}")


def main():
parser = argparse.ArgumentParser(description="API Command Line Interface")
parser.add_argument("--download", type=str, help="URL to download from")
parser.add_argument("--quality", type=str, help="The video quality (best,half,worst)")
parser.add_argument("--file", type=str, help="(Optional) Specify a file with URLs (separated with new lines)")
parser.add_argument("--output", type=str, help="The output path (with filename)")
args = parser.parse_args()

if args.download:
client = Client()
video = client.get_video(args.download)
video.download(quality=args.quality, path=args.output)

if args.file:
videos = []
client = Client()

with open(args.file, "r") as file:
content = file.read().splitlines()

for url in content:
videos.append(client.get_video(url))

for video in videos:
video.download(quality=args.quality, path=args.output)


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"requests", "lxml", "bs4", "eaf_base_api"
],
entry_points={
'console_scripts': [
'console_scripts': ['hqporner_api=hqporner_api.api:main'
# If you want to create any executable scripts
],
},
Expand Down

0 comments on commit 42f3b42

Please sign in to comment.