diff options
author | CoprDistGit <infra@openeuler.org> | 2023-04-10 18:10:50 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-04-10 18:10:50 +0000 |
commit | 6c2f20e5ca0203692a5fe516787ddb5d0199cecb (patch) | |
tree | 927e69221ad6b455c054cc367b4a4a86021ff915 | |
parent | e2de5b95a0e094caba83d270355d841445501773 (diff) |
automatic import of python-a-pytube-fork-for-spotdl-users
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-a-pytube-fork-for-spotdl-users.spec | 796 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 798 insertions, 0 deletions
@@ -0,0 +1 @@ +/a-pytube-fork-for-spotdl-users-9.6.4.tar.gz diff --git a/python-a-pytube-fork-for-spotdl-users.spec b/python-a-pytube-fork-for-spotdl-users.spec new file mode 100644 index 0000000..7efc42d --- /dev/null +++ b/python-a-pytube-fork-for-spotdl-users.spec @@ -0,0 +1,796 @@ +%global _empty_manifest_terminate_build 0 +Name: python-a-pytube-fork-for-spotdl-users +Version: 9.6.4 +Release: 1 +Summary: Python 3 library for downloading YouTube Videos. +License: MIT +URL: https://github.com/nficano/pytube +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/4a/fc/9ce6b21804567fee79f62215cec9a1a694be077e44adf42ce652203b9098/a-pytube-fork-for-spotdl-users-9.6.4.tar.gz +BuildArch: noarch + +Requires: python3-typing-extensions + +%description + + +## (24 JULY 2020) Note: Actively soliciting contributers! +Ping @ronncc if you would like to help out + +<div align="center"> + <p> + <img src="https://github.com/nficano/pytube/blob/master/images/pytube.png?raw=true" width="350" height="328" alt="pytube logo" /> + </p> + <p align="center"> + <img src="https://img.shields.io/pypi/v/pytube.svg" alt="pypi"> + <a href="https://travis-ci.org/nficano/pytube"><img src="https://travis-ci.org/nficano/pytube.svg?branch=master" /></a> + <a href="http://python-pytube.readthedocs.io/en/latest/?badge=latest"><img src="https://readthedocs.org/projects/python-pytube/badge/?version=latest" /></a> + <a href="https://coveralls.io/github/nficano/pytube?branch=master"><img src="https://coveralls.io/repos/github/nficano/pytube/badge.svg?branch=master#23e6f7ac56dd3bde" /></a> + <a href="https://pypi.org/project/pytube/"><img src="https://img.shields.io/pypi/dm/pytube.svg" alt="pypi"></a> + <a href="https://pypi.python.org/pypi/pytube/"><img src="https://img.shields.io/pypi/pyversions/pytube.svg" /></a> + <p> + </p> +</div> + +# pytube +*pytube* is a very serious, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos. + +## Description +YouTube is the most popular video-sharing platform in the world and as a hacker you may encounter a situation where you want to script something to download videos. For this I present to you *pytube*. + +*pytube* is a lightweight library written in Python. It has no third party dependencies and aims to be highly reliable. + +*pytube* also makes pipelining easy, allowing you to specify callback functions for different download events, such as ``on progress`` or ``on complete``. + +Finally *pytube* also includes a command-line utility, allowing you to quickly download videos right from terminal. + +### Behold, a perfect balance of simplicity versus flexibility: + +```python + >>> YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download() + >>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0') + >>> yt.streams + ... .filter(progressive=True, file_extension='mp4') + ... .order_by('resolution') + ... .desc() + ... .first() + ... .download() +``` + +## Features +- Support for Both Progressive & DASH Streams +- Support for downloading complete playlist +- Easily Register ``on_download_progress`` & ``on_download_complete`` callbacks +- Command-line Interfaced Included +- Caption Track Support +- Outputs Caption Tracks to .srt format (SubRip Subtitle) +- Ability to Capture Thumbnail URL. +- Extensively Documented Source Code +- No Third-Party Dependencies + +## Installation + +Download using pip via pypi. + +```bash +$ pip install pytube +``` + +## Getting started + +Let's begin with showing how easy it is to download a video with pytube: + +```python +>>> from pytube import YouTube +>>> YouTube('http://youtube.com/watch?v=9bZkp7q19f0').streams.first().download() +``` +This example will download the highest quality progressive download stream available. + +Next, let's explore how we would view what video streams are available: + +```python +>>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0') +>>> yt.streams.all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">, + <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">, + <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">, + <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">, + <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">, + <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">, + <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">, + <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">, + <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">, + <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">, + <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">, + <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">, + <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">, + <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">, + <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">, + <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">, + <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">, + <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">] +``` +You may notice that some streams listed have both a video codec and audio codec, while others have just video or just audio, this is a result of YouTube supporting a streaming technique called Dynamic Adaptive Streaming over HTTP (DASH). + +In the context of pytube, the implications are for the highest quality streams; you now need to download both the audio and video tracks and then post-process them with software like FFmpeg to merge them. + +The legacy streams that contain the audio and video in a single file (referred to as "progressive download") are still available, but only for resolutions 720p and below. + +To only view these progressive download streams: + +```python + >>> yt.streams.filter(progressive=True).all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">, + <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">, + <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">] +``` + +Conversely, if you only want to see the DASH streams (also referred to as "adaptive") you can do: + +```python +>>> yt.streams.filter(adaptive=True).all() + [<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">, + <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">, + <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">, + <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">, + <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">, + <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">, + <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">, + <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">, + <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">, + <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">, + <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">, + <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">, + <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">, + <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">, + <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">] +``` + +You can also download a complete Youtube playlist: + +```python +>>> from pytube import Playlist +>>> pl = Playlist("https://www.youtube.com/watch?v=Edpy1szoG80&list=PL153hDY-y1E00uQtCVCVC8xJ25TYX8yPU") +>>> pl.download_all() +>>> # or if you want to download in a specific directory +>>> pl.download_all('/path/to/directory/') +``` +This will download the highest progressive stream available (generally 720p) from the given playlist. Later more options would be given for user's flexibility +to choose video resolution. + +Pytube allows you to filter on every property available (see the documentation for the complete list), let's take a look at some of the most useful ones. + +To list the audio only streams: + +```python +>>> yt.streams.filter(only_audio=True).all() + [<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">, + <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">, + <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">, + <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">, + <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">] +``` + +To list only ``mp4`` streams: + +```python +>>> yt.streams.filter(subtype='mp4').all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">, + <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">, + <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">, + <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">, + <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">, + <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">] +``` + +Multiple filters can also be specified: + +```python +>>> yt.streams.filter(subtype='mp4', progressive=True).all() +>>> # this can also be expressed as: +>>> yt.streams.filter(subtype='mp4').filter(progressive=True).all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">] +``` +You also have an interface to select streams by their itag, without needing to filter: + +```python +>>> yt.streams.get_by_itag(22) + <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2"> +``` + +If you need to optimize for a specific feature, such as the "highest resolution" or "lowest average bitrate": + +```python +>>> yt.streams.filter(progressive=True).order_by('resolution').desc().all() +``` +Note that ``order_by`` cannot be used if your attribute is undefined in any of the Stream instances, so be sure to apply a filter to remove those before calling it. + +If your application requires post-processing logic, pytube allows you to specify an "on download complete" callback function: + +```python + >>> def convert_to_aac(stream, file_handle): + return # do work + + >>> yt.register_on_complete_callback(convert_to_aac) +``` + +Similarly, if your application requires on-download progress logic, pytube exposes a callback for this as well: + +```python + >>> def show_progress_bar(stream, chunk, file_handle, bytes_remaining): + return # do work + + >>> yt.register_on_progress_callback(show_progress_bar) +``` + +## Command-line interface + +pytube also ships with a tiny cli interface for downloading and probing videos. + +Let's start with downloading: + +```bash +$ pytube http://youtube.com/watch?v=9bZkp7q19f0 --itag=22 +``` +To view available streams: + +```bash +$ pytube http://youtube.com/watch?v=9bZkp7q19f0 --list +``` + +Finally, if you're filing a bug report, the cli contains a switch called ``--build-playback-report``, which bundles up the state, allowing others to easily replay your issue. + + + + +%package -n python3-a-pytube-fork-for-spotdl-users +Summary: Python 3 library for downloading YouTube Videos. +Provides: python-a-pytube-fork-for-spotdl-users +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-a-pytube-fork-for-spotdl-users + + +## (24 JULY 2020) Note: Actively soliciting contributers! +Ping @ronncc if you would like to help out + +<div align="center"> + <p> + <img src="https://github.com/nficano/pytube/blob/master/images/pytube.png?raw=true" width="350" height="328" alt="pytube logo" /> + </p> + <p align="center"> + <img src="https://img.shields.io/pypi/v/pytube.svg" alt="pypi"> + <a href="https://travis-ci.org/nficano/pytube"><img src="https://travis-ci.org/nficano/pytube.svg?branch=master" /></a> + <a href="http://python-pytube.readthedocs.io/en/latest/?badge=latest"><img src="https://readthedocs.org/projects/python-pytube/badge/?version=latest" /></a> + <a href="https://coveralls.io/github/nficano/pytube?branch=master"><img src="https://coveralls.io/repos/github/nficano/pytube/badge.svg?branch=master#23e6f7ac56dd3bde" /></a> + <a href="https://pypi.org/project/pytube/"><img src="https://img.shields.io/pypi/dm/pytube.svg" alt="pypi"></a> + <a href="https://pypi.python.org/pypi/pytube/"><img src="https://img.shields.io/pypi/pyversions/pytube.svg" /></a> + <p> + </p> +</div> + +# pytube +*pytube* is a very serious, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos. + +## Description +YouTube is the most popular video-sharing platform in the world and as a hacker you may encounter a situation where you want to script something to download videos. For this I present to you *pytube*. + +*pytube* is a lightweight library written in Python. It has no third party dependencies and aims to be highly reliable. + +*pytube* also makes pipelining easy, allowing you to specify callback functions for different download events, such as ``on progress`` or ``on complete``. + +Finally *pytube* also includes a command-line utility, allowing you to quickly download videos right from terminal. + +### Behold, a perfect balance of simplicity versus flexibility: + +```python + >>> YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download() + >>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0') + >>> yt.streams + ... .filter(progressive=True, file_extension='mp4') + ... .order_by('resolution') + ... .desc() + ... .first() + ... .download() +``` + +## Features +- Support for Both Progressive & DASH Streams +- Support for downloading complete playlist +- Easily Register ``on_download_progress`` & ``on_download_complete`` callbacks +- Command-line Interfaced Included +- Caption Track Support +- Outputs Caption Tracks to .srt format (SubRip Subtitle) +- Ability to Capture Thumbnail URL. +- Extensively Documented Source Code +- No Third-Party Dependencies + +## Installation + +Download using pip via pypi. + +```bash +$ pip install pytube +``` + +## Getting started + +Let's begin with showing how easy it is to download a video with pytube: + +```python +>>> from pytube import YouTube +>>> YouTube('http://youtube.com/watch?v=9bZkp7q19f0').streams.first().download() +``` +This example will download the highest quality progressive download stream available. + +Next, let's explore how we would view what video streams are available: + +```python +>>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0') +>>> yt.streams.all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">, + <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">, + <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">, + <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">, + <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">, + <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">, + <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">, + <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">, + <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">, + <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">, + <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">, + <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">, + <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">, + <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">, + <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">, + <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">, + <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">, + <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">] +``` +You may notice that some streams listed have both a video codec and audio codec, while others have just video or just audio, this is a result of YouTube supporting a streaming technique called Dynamic Adaptive Streaming over HTTP (DASH). + +In the context of pytube, the implications are for the highest quality streams; you now need to download both the audio and video tracks and then post-process them with software like FFmpeg to merge them. + +The legacy streams that contain the audio and video in a single file (referred to as "progressive download") are still available, but only for resolutions 720p and below. + +To only view these progressive download streams: + +```python + >>> yt.streams.filter(progressive=True).all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">, + <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">, + <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">] +``` + +Conversely, if you only want to see the DASH streams (also referred to as "adaptive") you can do: + +```python +>>> yt.streams.filter(adaptive=True).all() + [<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">, + <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">, + <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">, + <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">, + <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">, + <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">, + <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">, + <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">, + <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">, + <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">, + <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">, + <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">, + <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">, + <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">, + <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">] +``` + +You can also download a complete Youtube playlist: + +```python +>>> from pytube import Playlist +>>> pl = Playlist("https://www.youtube.com/watch?v=Edpy1szoG80&list=PL153hDY-y1E00uQtCVCVC8xJ25TYX8yPU") +>>> pl.download_all() +>>> # or if you want to download in a specific directory +>>> pl.download_all('/path/to/directory/') +``` +This will download the highest progressive stream available (generally 720p) from the given playlist. Later more options would be given for user's flexibility +to choose video resolution. + +Pytube allows you to filter on every property available (see the documentation for the complete list), let's take a look at some of the most useful ones. + +To list the audio only streams: + +```python +>>> yt.streams.filter(only_audio=True).all() + [<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">, + <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">, + <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">, + <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">, + <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">] +``` + +To list only ``mp4`` streams: + +```python +>>> yt.streams.filter(subtype='mp4').all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">, + <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">, + <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">, + <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">, + <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">, + <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">] +``` + +Multiple filters can also be specified: + +```python +>>> yt.streams.filter(subtype='mp4', progressive=True).all() +>>> # this can also be expressed as: +>>> yt.streams.filter(subtype='mp4').filter(progressive=True).all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">] +``` +You also have an interface to select streams by their itag, without needing to filter: + +```python +>>> yt.streams.get_by_itag(22) + <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2"> +``` + +If you need to optimize for a specific feature, such as the "highest resolution" or "lowest average bitrate": + +```python +>>> yt.streams.filter(progressive=True).order_by('resolution').desc().all() +``` +Note that ``order_by`` cannot be used if your attribute is undefined in any of the Stream instances, so be sure to apply a filter to remove those before calling it. + +If your application requires post-processing logic, pytube allows you to specify an "on download complete" callback function: + +```python + >>> def convert_to_aac(stream, file_handle): + return # do work + + >>> yt.register_on_complete_callback(convert_to_aac) +``` + +Similarly, if your application requires on-download progress logic, pytube exposes a callback for this as well: + +```python + >>> def show_progress_bar(stream, chunk, file_handle, bytes_remaining): + return # do work + + >>> yt.register_on_progress_callback(show_progress_bar) +``` + +## Command-line interface + +pytube also ships with a tiny cli interface for downloading and probing videos. + +Let's start with downloading: + +```bash +$ pytube http://youtube.com/watch?v=9bZkp7q19f0 --itag=22 +``` +To view available streams: + +```bash +$ pytube http://youtube.com/watch?v=9bZkp7q19f0 --list +``` + +Finally, if you're filing a bug report, the cli contains a switch called ``--build-playback-report``, which bundles up the state, allowing others to easily replay your issue. + + + + +%package help +Summary: Development documents and examples for a-pytube-fork-for-spotdl-users +Provides: python3-a-pytube-fork-for-spotdl-users-doc +%description help + + +## (24 JULY 2020) Note: Actively soliciting contributers! +Ping @ronncc if you would like to help out + +<div align="center"> + <p> + <img src="https://github.com/nficano/pytube/blob/master/images/pytube.png?raw=true" width="350" height="328" alt="pytube logo" /> + </p> + <p align="center"> + <img src="https://img.shields.io/pypi/v/pytube.svg" alt="pypi"> + <a href="https://travis-ci.org/nficano/pytube"><img src="https://travis-ci.org/nficano/pytube.svg?branch=master" /></a> + <a href="http://python-pytube.readthedocs.io/en/latest/?badge=latest"><img src="https://readthedocs.org/projects/python-pytube/badge/?version=latest" /></a> + <a href="https://coveralls.io/github/nficano/pytube?branch=master"><img src="https://coveralls.io/repos/github/nficano/pytube/badge.svg?branch=master#23e6f7ac56dd3bde" /></a> + <a href="https://pypi.org/project/pytube/"><img src="https://img.shields.io/pypi/dm/pytube.svg" alt="pypi"></a> + <a href="https://pypi.python.org/pypi/pytube/"><img src="https://img.shields.io/pypi/pyversions/pytube.svg" /></a> + <p> + </p> +</div> + +# pytube +*pytube* is a very serious, lightweight, dependency-free Python library (and command-line utility) for downloading YouTube Videos. + +## Description +YouTube is the most popular video-sharing platform in the world and as a hacker you may encounter a situation where you want to script something to download videos. For this I present to you *pytube*. + +*pytube* is a lightweight library written in Python. It has no third party dependencies and aims to be highly reliable. + +*pytube* also makes pipelining easy, allowing you to specify callback functions for different download events, such as ``on progress`` or ``on complete``. + +Finally *pytube* also includes a command-line utility, allowing you to quickly download videos right from terminal. + +### Behold, a perfect balance of simplicity versus flexibility: + +```python + >>> YouTube('https://youtu.be/9bZkp7q19f0').streams.first().download() + >>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0') + >>> yt.streams + ... .filter(progressive=True, file_extension='mp4') + ... .order_by('resolution') + ... .desc() + ... .first() + ... .download() +``` + +## Features +- Support for Both Progressive & DASH Streams +- Support for downloading complete playlist +- Easily Register ``on_download_progress`` & ``on_download_complete`` callbacks +- Command-line Interfaced Included +- Caption Track Support +- Outputs Caption Tracks to .srt format (SubRip Subtitle) +- Ability to Capture Thumbnail URL. +- Extensively Documented Source Code +- No Third-Party Dependencies + +## Installation + +Download using pip via pypi. + +```bash +$ pip install pytube +``` + +## Getting started + +Let's begin with showing how easy it is to download a video with pytube: + +```python +>>> from pytube import YouTube +>>> YouTube('http://youtube.com/watch?v=9bZkp7q19f0').streams.first().download() +``` +This example will download the highest quality progressive download stream available. + +Next, let's explore how we would view what video streams are available: + +```python +>>> yt = YouTube('http://youtube.com/watch?v=9bZkp7q19f0') +>>> yt.streams.all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">, + <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">, + <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">, + <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">, + <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">, + <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">, + <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">, + <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">, + <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">, + <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">, + <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">, + <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">, + <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">, + <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">, + <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">, + <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">, + <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">, + <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">] +``` +You may notice that some streams listed have both a video codec and audio codec, while others have just video or just audio, this is a result of YouTube supporting a streaming technique called Dynamic Adaptive Streaming over HTTP (DASH). + +In the context of pytube, the implications are for the highest quality streams; you now need to download both the audio and video tracks and then post-process them with software like FFmpeg to merge them. + +The legacy streams that contain the audio and video in a single file (referred to as "progressive download") are still available, but only for resolutions 720p and below. + +To only view these progressive download streams: + +```python + >>> yt.streams.filter(progressive=True).all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="43" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp8.0" acodec="vorbis">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">, + <Stream: itag="36" mime_type="video/3gpp" res="240p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">, + <Stream: itag="17" mime_type="video/3gpp" res="144p" fps="30fps" vcodec="mp4v.20.3" acodec="mp4a.40.2">] +``` + +Conversely, if you only want to see the DASH streams (also referred to as "adaptive") you can do: + +```python +>>> yt.streams.filter(adaptive=True).all() + [<Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">, + <Stream: itag="248" mime_type="video/webm" res="1080p" fps="30fps" vcodec="vp9">, + <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">, + <Stream: itag="247" mime_type="video/webm" res="720p" fps="30fps" vcodec="vp9">, + <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="244" mime_type="video/webm" res="480p" fps="30fps" vcodec="vp9">, + <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="243" mime_type="video/webm" res="360p" fps="30fps" vcodec="vp9">, + <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">, + <Stream: itag="242" mime_type="video/webm" res="240p" fps="30fps" vcodec="vp9">, + <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">, + <Stream: itag="278" mime_type="video/webm" res="144p" fps="30fps" vcodec="vp9">, + <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">, + <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">, + <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">, + <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">, + <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">] +``` + +You can also download a complete Youtube playlist: + +```python +>>> from pytube import Playlist +>>> pl = Playlist("https://www.youtube.com/watch?v=Edpy1szoG80&list=PL153hDY-y1E00uQtCVCVC8xJ25TYX8yPU") +>>> pl.download_all() +>>> # or if you want to download in a specific directory +>>> pl.download_all('/path/to/directory/') +``` +This will download the highest progressive stream available (generally 720p) from the given playlist. Later more options would be given for user's flexibility +to choose video resolution. + +Pytube allows you to filter on every property available (see the documentation for the complete list), let's take a look at some of the most useful ones. + +To list the audio only streams: + +```python +>>> yt.streams.filter(only_audio=True).all() + [<Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">, + <Stream: itag="171" mime_type="audio/webm" abr="128kbps" acodec="vorbis">, + <Stream: itag="249" mime_type="audio/webm" abr="50kbps" acodec="opus">, + <Stream: itag="250" mime_type="audio/webm" abr="70kbps" acodec="opus">, + <Stream: itag="251" mime_type="audio/webm" abr="160kbps" acodec="opus">] +``` + +To list only ``mp4`` streams: + +```python +>>> yt.streams.filter(subtype='mp4').all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">, + <Stream: itag="137" mime_type="video/mp4" res="1080p" fps="30fps" vcodec="avc1.640028">, + <Stream: itag="136" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.4d401f">, + <Stream: itag="135" mime_type="video/mp4" res="480p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="134" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.4d401e">, + <Stream: itag="133" mime_type="video/mp4" res="240p" fps="30fps" vcodec="avc1.4d4015">, + <Stream: itag="160" mime_type="video/mp4" res="144p" fps="30fps" vcodec="avc1.4d400c">, + <Stream: itag="140" mime_type="audio/mp4" abr="128kbps" acodec="mp4a.40.2">] +``` + +Multiple filters can also be specified: + +```python +>>> yt.streams.filter(subtype='mp4', progressive=True).all() +>>> # this can also be expressed as: +>>> yt.streams.filter(subtype='mp4').filter(progressive=True).all() + [<Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2">, + <Stream: itag="18" mime_type="video/mp4" res="360p" fps="30fps" vcodec="avc1.42001E" acodec="mp4a.40.2">] +``` +You also have an interface to select streams by their itag, without needing to filter: + +```python +>>> yt.streams.get_by_itag(22) + <Stream: itag="22" mime_type="video/mp4" res="720p" fps="30fps" vcodec="avc1.64001F" acodec="mp4a.40.2"> +``` + +If you need to optimize for a specific feature, such as the "highest resolution" or "lowest average bitrate": + +```python +>>> yt.streams.filter(progressive=True).order_by('resolution').desc().all() +``` +Note that ``order_by`` cannot be used if your attribute is undefined in any of the Stream instances, so be sure to apply a filter to remove those before calling it. + +If your application requires post-processing logic, pytube allows you to specify an "on download complete" callback function: + +```python + >>> def convert_to_aac(stream, file_handle): + return # do work + + >>> yt.register_on_complete_callback(convert_to_aac) +``` + +Similarly, if your application requires on-download progress logic, pytube exposes a callback for this as well: + +```python + >>> def show_progress_bar(stream, chunk, file_handle, bytes_remaining): + return # do work + + >>> yt.register_on_progress_callback(show_progress_bar) +``` + +## Command-line interface + +pytube also ships with a tiny cli interface for downloading and probing videos. + +Let's start with downloading: + +```bash +$ pytube http://youtube.com/watch?v=9bZkp7q19f0 --itag=22 +``` +To view available streams: + +```bash +$ pytube http://youtube.com/watch?v=9bZkp7q19f0 --list +``` + +Finally, if you're filing a bug report, the cli contains a switch called ``--build-playback-report``, which bundles up the state, allowing others to easily replay your issue. + + + + +%prep +%autosetup -n a-pytube-fork-for-spotdl-users-9.6.4 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-a-pytube-fork-for-spotdl-users -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon Apr 10 2023 Python_Bot <Python_Bot@openeuler.org> - 9.6.4-1 +- Package Spec generated @@ -0,0 +1 @@ +fc7da435cf89c515a4becbff5d8ad502 a-pytube-fork-for-spotdl-users-9.6.4.tar.gz |