Skip to content

Commit

Permalink
- Implemented #2
Browse files Browse the repository at this point in the history
  • Loading branch information
EchterAlsFake committed Apr 4, 2024
1 parent 1160799 commit c7741c9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ video_object.download(downloader=threaded, quality=Quality.BEST, path="your_outp
# 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/xvideos_api/blob/master/README/Changelog.md) for more details.

Expand Down
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", "bs4", "lxml", "ffmpeg-progress-yield", "eaf_base_api"
],
entry_points={
'console_scripts': [
'console_scripts': ['xvideos_api=xvideos_api.xvideos_api:main'
# If you want to create any executable scripts
],
},
Expand Down
33 changes: 33 additions & 0 deletions xvideos_api/xvideos_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import json
import html
import logging
import argparse

from bs4 import BeautifulSoup
from functools import cached_property
Expand Down Expand Up @@ -294,3 +295,35 @@ def search(cls, query, sorting_Sort: Sort = Sort.Sort_relevance, sorting_Date: S

for id in urls:
yield Video(id)


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("--downloader", type=str, help="The downloader for the segments (threaded,ffmpeg,default)")
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(downloader=args.downloader, 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, downloader=args.downloader, path=args.output)


if __name__ == "__main__":
main()

0 comments on commit c7741c9

Please sign in to comment.