Skip to content

Commit

Permalink
✨ download videos from playlist
Browse files Browse the repository at this point in the history
  • Loading branch information
lonsty committed Mar 14, 2021
1 parent 721c92e commit 474e177
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 50 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ xvideos-dl --help
xvideos-dl https://www.xvideos.com/video37177493/asian_webcam_2_camsex4u.life
```

## Release History

### 1.0.1

New features:

- Download videos from playlist
- Show download speed

### 1.0.0

Initial release on PyPY.

<hr>

## For Contributors
Expand Down
29 changes: 20 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "xvideos-dl"
version = "1.0.0"
version = "1.0.1"
description = "CLI to download videos from https://xvideos.com"
readme = "README.md"
authors = [
Expand Down Expand Up @@ -36,6 +36,7 @@ python = "^3.7"
importlib_metadata = {version = "^1.6.0", python = "<3.8"}
typer = {extras = ["all"], version = "^0.3.2"}
rich = "^9.8.2"
cursor = "^1.3.4"
requests = "^2.25.0"

[tool.poetry.dev-dependencies]
Expand Down
20 changes: 17 additions & 3 deletions xvideos_dl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import sys

import typer
from cursor import HiddenCursor
from rich.console import Console
from xvideos_dl import __version__
from xvideos_dl.xvideos_dl import download
from xvideos_dl.xvideos_dl import download, get_videos_by_playlist_id, get_videos_from_play_page, parse_playlist_id

app = typer.Typer(
name="xvideos-dl",
Expand All @@ -26,13 +27,15 @@ def version_callback(value: bool):
@app.command(name="")
def main(
url: List[str] = typer.Argument(..., help="URL of the video web page."),
playlist: bool = typer.Option(False, "-p", "--playlist", help="Download videos from playlist web page."),
dest: str = typer.Option(
"./xvideos",
"-d",
"--destination",
help="Destination to save the downloaded videos.",
),
low: bool = typer.Option(False, "-l", "--low-definition", help="Download low definition videos."),
overwrite: bool = typer.Option(False, "-O", "--overwrite", help="Overwrite the exist video files."),
version: bool = typer.Option(
None,
"-v",
Expand All @@ -43,9 +46,20 @@ def main(
),
):
"""CLI to download videos from https://xvideos.com"""
for one in url:
videos = []
if playlist:
pids = [parse_playlist_id(u) for u in url]
for pid in pids:
vs = get_videos_by_playlist_id(pid)
videos.extend(vs)
else:
for page_url in url:
videos.append(get_videos_from_play_page(page_url))

for video in videos:
try:
download(one, dest, low)
with HiddenCursor():
download(video, dest, low, overwrite)
except Exception as e:
console.print(f"[red]{e}[/]")
sys.exit(1)
2 changes: 2 additions & 0 deletions xvideos_dl/constant.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
APP_NAME = "xvideos-dl"
FAVORITE_API = "https://www.xvideos.com/api/playlists/alpha"
PLAYLIST_API = "https://www.xvideos.com/api/playlists/list/{pid}"
VIDEO_API = "https://www.xvideos.com/video-download/{vid}/"
TIMEOUT = 10 # seconds
FRAGMENT_SIZE = 1024 ** 2 * 16 # 16MB
Expand Down

0 comments on commit 474e177

Please sign in to comment.