Skip to content

Commit

Permalink
✨ download user's uploaded & channel published
Browse files Browse the repository at this point in the history
  • Loading branch information
lonsty committed Mar 16, 2021
1 parent 474e177 commit a05eafe
Show file tree
Hide file tree
Showing 8 changed files with 303 additions and 51 deletions.
29 changes: 24 additions & 5 deletions README.md
Expand Up @@ -16,6 +16,16 @@ CLI to download videos from https://xvideos.com

</div>

<div align="center"><a href="README_CN.md">中文文档</a></div>

## Features

-[X] Download a single video (requires the URL of the video playback page)
-[X] Download all videos in the favorites (requires the URL of the favorite page)
-[X] Download all videos uploaded by the user (requires the URL of the user's homepage)
-[X] Download all videos published by the channel (requires the URL of the channel homepage)
-[X] Segmented high-speed download, breakpoint download, progress and status display

## Usage

- Install xvideos-dl
Expand All @@ -30,20 +40,29 @@ pip install -U xvideos-dl
xvideos-dl --help
```

- Download video
- Download single / favorites / uploaded / published videos in one command:

```bash
xvideos-dl https://www.xvideos.com/video37177493/asian_webcam_2_camsex4u.life
xvideos-dl https://www.xvideos.com/video37177493/asian_webcam_2_camsex4u.life https://www.xvideos.com/favorite/71879935/_ https://www.xvideos.com/profiles/mypornstation https://www.xvideos.com/channels/av69tv
```

## Release History

### 1.1.0

New Features:

- Download all videos uploaded by users.
- Download all videos posted by the channel.
- Download single, playlist, user uploaded and channel posted videos in one command.
- Optimize download status display.

### 1.0.1

New features:
New Features:

- Download videos from playlist
- Show download speed
- Download videos from playlist.
- Show download speed.

### 1.0.0

Expand Down
73 changes: 73 additions & 0 deletions README_CN.md
@@ -0,0 +1,73 @@
# xvideos-dl

<div align="center">

[![Build status](https://github.com/lonsty/xvideos-dl/workflows/build/badge.svg?branch=master&event=push)](https://github.com/lonsty/xvideos-dl/actions?query=workflow%3Abuild)
[![Python Version](https://img.shields.io/pypi/pyversions/xvideos-dl.svg)](https://pypi.org/project/xvideos-dl/)
[![Dependencies Status](https://img.shields.io/badge/dependencies-up%20to%20date-brightgreen.svg)](https://github.com/lonsty/xvideos-dl/pulls?utf8=%E2%9C%93&q=is%3Apr%20author%3Aapp%2Fdependabot)

[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Security: bandit](https://img.shields.io/badge/security-bandit-green.svg)](https://github.com/PyCQA/bandit)
[![Pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/lonsty/xvideos-dl/blob/master/.pre-commit-config.yaml)
[![Semantic Versions](https://img.shields.io/badge/%F0%9F%9A%80-semantic%20versions-informational.svg)](https://github.com/lonsty/xvideos-dl/releases)
[![License](https://img.shields.io/github/license/lonsty/xvideos-dl)](https://github.com/lonsty/xvideos-dl/blob/master/LICENSE)

https://xvideos.com H 片命令行下载工具

</div>

## 工具特点

- [X] 下载单个视频(需视频播放页的 URL)
- [X] 下载收藏夹中的所有视频(需收藏夹页的 URL)
- [X] 下载用户上传的所有视频(需用户首页的 URL)
- [X] 下载频道发布的所有视频(需频道首页的 URL)
- [X] 分段高速下载,断点下载,进度与状态显示

## 使用说明

### 安装工具 xvideos-dl

```bash
pip install -U xvideos-dl
```

### 获取工具使用帮助

```bash
xvideos-dl --help
```

### 下载视频

*注意:首此使用时,程序会出现提示语要求输入 Cookie,用个人账号登录 https://xvideos.com 获取 Cookie 粘贴到终端,即可继续运行。Cookie 可以长期使用。*

只需一行命令,下载单个 / 收藏夹 / 用户上传 / 频道发布 的所有视频

```bash
xvideos-dl https://www.xvideos.com/video37177493/asian_webcam_2_camsex4u.life https://www.xvideos.com/favorite/71879935/_ https://www.xvideos.com/profiles/mypornstation https://www.xvideos.com/channels/av69tv
```

![示例](demo_1.PNG)

## Release History

### 1.1.0

New Features:

- Download all videos uploaded by users.
- Download all videos posted by the channel.
- Download single, playlist, user uploaded and channel posted videos in one command.
- Optimize download status display.

### 1.0.1

New Features:

- Download all videos in playlists.
- Show download speed.

### 1.0.0

Initial release on PyPY.
Binary file added demo_1.PNG
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 43 additions & 11 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
Expand Up @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "xvideos-dl"
version = "1.0.1"
version = "1.1.0"
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"
beautifulsoup4 = "^4.9.0"
cursor = "^1.3.4"
requests = "^2.25.0"

Expand Down
56 changes: 41 additions & 15 deletions xvideos_dl/__main__.py
Expand Up @@ -7,7 +7,16 @@
from cursor import HiddenCursor
from rich.console import Console
from xvideos_dl import __version__
from xvideos_dl.xvideos_dl import download, get_videos_by_playlist_id, get_videos_from_play_page, parse_playlist_id
from xvideos_dl.xvideos_dl import (
Process,
download,
get_videos_by_playlist_id,
get_videos_from_play_page,
get_videos_from_user_page,
parse_playlist_id,
)

from . import constant as c

app = typer.Typer(
name="xvideos-dl",
Expand All @@ -24,18 +33,19 @@ def version_callback(value: bool):
raise typer.Exit()


@app.command(name="")
@app.command(name="CLI to download videos from https://xvideos.com")
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."),
urls: List[str] = typer.Argument(..., help="URL of the video web page."),
dest: str = typer.Option(
"./xvideos",
"-d",
"--destination",
help="Destination to save the downloaded videos.",
),
max: int = typer.Option(None, "-n", "--maximum", help="Maximum videos to download."),
reversed: bool = typer.Option(False, "-r", "--reversed", help="Download videos in reverse order."),
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."),
overwrite: bool = typer.Option(False, "-o", "--overwrite", help="Overwrite the exist video files."),
version: bool = typer.Option(
None,
"-v",
Expand All @@ -46,19 +56,35 @@ def main(
),
):
"""CLI to download videos from https://xvideos.com"""
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))
videos_to_download = []
for url in urls:
if "/profiles/" in url:
videos = []
videos = get_videos_from_user_page(url, "0", c.USER_UPLOAD_API, videos)
videos_to_download.extend(videos)
elif "/channels/" in url:
videos = []
videos = get_videos_from_user_page(url, "0", c.CHANNEL_API, videos)
videos_to_download.extend(videos)
elif "/favorite/" in url:
pid = parse_playlist_id(url)
videos = get_videos_by_playlist_id(pid)
videos_to_download.extend(videos)
else:
video = get_videos_from_play_page(url)
videos_to_download.append(video)

if reversed:
videos_to_download = videos_to_download[::-1]
if max:
videos_to_download = videos_to_download[:max]

for video in videos:
total = len(videos_to_download)
for idx, video in enumerate(videos_to_download):
try:
with HiddenCursor():
process = Process(idx + 1, total)
console.print(f"Downloading: [cyan]{process.status()}[/]")
download(video, dest, low, overwrite)
except Exception as e:
console.print(f"[red]{e}[/]")
Expand Down

0 comments on commit a05eafe

Please sign in to comment.