Skip to content

Commit

Permalink
Switch default installation to yt-dlp
Browse files Browse the repository at this point in the history
  • Loading branch information
woefe committed Nov 24, 2021
1 parent 34e987e commit 14cbf5b
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 36 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ See the [migration guide](https://github.com/woefe/ytcc/tree/master/doc/migrate.

Add "subscriptions".
```shell script
# Any playlist supported by youtube-dl
# Any playlist supported by yt-dlp (or youtube-dl)
ytcc subscribe "Jupiter Broadcasting" "https://www.youtube.com/c/JupiterBroadcasting/videos"
ytcc subscribe "NCS: House" "https://www.youtube.com/playlist?list=PLRBp0Fe2GpgmsW46rJyudVFlY6IYjFBIK"
ytcc subscribe "Neus" "https://soundcloud.com/neus/tracks"
Expand Down Expand Up @@ -163,11 +163,11 @@ default_action = play_video


[youtube_dl]
# Format (see FORMAT SELECTION in youtube-dl manpage). Make sure to use a video format here, if you
# Format (see FORMAT SELECTION in yt-dlp manpage). Make sure to use a video format here, if you
# want to be able to download videos.
format = bestvideo[height<=?1080]+bestaudio/best

# Output template (see OUTPUT TEMPLATE in youtube-dl manpage).
# Output template (see OUTPUT TEMPLATE in yt-dlp manpage).
# Note that the output template will be prefixed with the `download_dir` directory and the name of
# the playlist if `download_sub_dir` is enabled.
output_template = %(title)s.%(ext)s
Expand Down
1 change: 0 additions & 1 deletion devrequirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ pydocstyle
# Application dependencies
click
wcwidth
youtube_dl
yt_dlp
5 changes: 2 additions & 3 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
```shell script
pip install ytcc
```
Or alternatively with [yt-dlp](https://github.com/yt-dlp/yt-dlp): `pip install ytcc[yt_dlp]`

## Arch Linux
Install [ytcc](https://aur.archlinux.org/packages/ytcc/) or [ytcc-git](https://aur.archlinux.org/packages/ytcc-git/) from the AUR.
Expand Down Expand Up @@ -46,11 +45,11 @@ You can start ytcc directly from the cloned repo, if all requirements are instal
Hard requirements:
- [Python 3.7](https://www.python.org/) or later
- [Click](https://click.palletsprojects.com/en/7.x/)
- [youtube-dl](https://github.com/ytdl-org/youtube-dl)
- [yt-dlp](https://github.com/yt-dlp/yt-dlp) or [youtube-dl](https://github.com/ytdl-org/youtube-dl)
- [wcwidth](https://github.com/jquast/wcwidth)

Optional requirements:
- [ffmpeg](https://ffmpeg.org/) for youtube-dl's `.mp4` or `.mkv` merging
- [ffmpeg](https://ffmpeg.org/) for `.mp4` or `.mkv` merging
- [mpv](https://mpv.io/), if you want to play audio or video

Requirements for the ytccf.sh bash script:
Expand Down
12 changes: 6 additions & 6 deletions doc/ytcc.1
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.TH ytcc 1 "Nov 2021" "2.5.3" "ytcc - a subscription wrapper for youtube-dl"
.TH ytcc 1 "Nov 2021" "2.5.3" "ytcc manual"
.SH NAME
ytcc - a subscription wrapper for youtube-dl playlists
ytcc - Command line tool to keep track of your favorite playlists on YouTube and many other places
.SH SYNOPSIS
ytcc [OPTIONS...] COMMAND [ARGS...]
.SH DESCRIPTION
Ytcc - the (not only) YouTube channel checker.

Ytcc "subscribes" to playlists (supported by youtube-dl) and tracks new videos published to
those playlists.
Ytcc "subscribes" to playlists (supported by yt-dlp or youtube-dl) and tracks new videos
published to those playlists.

To show the detailed help of a COMMAND run `ytcc COMMAND --help`.

Expand All @@ -32,7 +32,7 @@ Show help and exit.
Subscribe to a playlist.

The NAME argument is the name used to refer to the playlist. The URL argument is the URL to a
playlist that is supported by youtube-dl.
playlist that is supported by yt-dlp or youtube-dl.
.P
.B OPTIONS:
.P
Expand Down Expand Up @@ -336,7 +336,7 @@ the output of this command when filing a new bug report!
.B --help
Show command help and exit.
.SH SEE ALSO
mpv(1), youtube-dl(1)
mpv(1), yt-dlp(1), youtube-dl(1)
.SS Project homepage
https://github.com/woefe/ytcc
.SS Bug Tracker
Expand Down
7 changes: 4 additions & 3 deletions scripts/make_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ def main():
with open("doc/ytcc.1", "w", encoding="utf-8") as manpage:
today = date.today().strftime('%b %Y')
manpage.write(f'.TH ytcc 1 "{today}" "{__version__}" ')
manpage.write('"ytcc - a subscription wrapper for youtube-dl"\n')
manpage.write('"ytcc manual"\n')
manpage.write(".SH NAME\n")
manpage.write("ytcc - a subscription wrapper for youtube-dl playlists\n")
manpage.write("ytcc - Command line tool to keep track of your favorite playlists on "
"YouTube and many other places\n")
manpage.write(".SH SYNOPSIS\n")
manpage.write("ytcc [OPTIONS...] COMMAND [ARGS...]\n")

Expand Down Expand Up @@ -80,7 +81,7 @@ def main():
manpage.write("\nShow command help and exit.\n")

manpage.write(".SH SEE ALSO\n"
"mpv(1), youtube-dl(1)\n"
"mpv(1), yt-dlp(1), youtube-dl(1)\n"
".SS Project homepage\n"
"https://github.com/woefe/ytcc\n"
".SS Bug Tracker\n"
Expand Down
3 changes: 1 addition & 2 deletions scripts/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ def usage():
core_v2.add_playlist(c_name, url)
except ytcc.BadURLException:
print(
f"Ignoring {c_name}, because it is not supported by "
"youtube-dl or does not exist any more"
f"Ignoring {c_name}, because it is not supported or does not exist any more"
)
continue
except ytcc.NameConflictError:
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

setup(
name="ytcc",
description="A subscription wrapper for youtube-dl playlists",
description="Command line tool to keep track of your favorite playlists",
long_description=long_description,
long_description_content_type="text/markdown",
version=ytcc.__version__,
Expand All @@ -17,9 +17,9 @@
author_email=ytcc.__email__,
license=ytcc.__license__,
packages=find_packages(exclude=["test"]),
install_requires=["youtube_dl", "click>=8.0", "wcwidth"],
install_requires=["yt_dlp", "click>=8.0", "wcwidth"],
extras_require={
"yt_dlp": ["yt_dlp"]
"youtube_dl": ["youtube_dl"]
},
python_requires=">=3.7, <4",
scripts=["scripts/ytccf.sh"],
Expand Down
2 changes: 1 addition & 1 deletion test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_subscribe_bad_url(cli_runner, caplog):
with cli_runner() as runner:
result = runner("subscribe", "Test", "test.kom")
assert result.exit_code != 0
msg = "The given URL does not point to a playlist or is not supported by youtube-dl"
msg = "The given URL does not point to a playlist or is not supported"
assert any(map(lambda r: r.msg == msg, caplog.records))


Expand Down
9 changes: 4 additions & 5 deletions ytcc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ def cli(ctx: click.Context, conf: Path, loglevel: str, output: str, separator: s
truncate: Union[None, str, int]) -> None:
"""Ytcc - the (not only) YouTube channel checker.
Ytcc "subscribes" to playlists (supported by youtube-dl) and tracks new videos published to
those playlists.
Ytcc "subscribes" to playlists (supported by yt-dlp or youtube-dl) and tracks new videos
published to those playlists.
To show the detailed help of a COMMAND run `ytcc COMMAND --help`.
"""
Expand Down Expand Up @@ -242,13 +242,12 @@ def subscribe(ytcc: core.Ytcc, name: str, url: str, reverse: bool):
"""Subscribe to a playlist.
The NAME argument is the name used to refer to the playlist. The URL argument is the URL to a
playlist that is supported by youtube-dl.
playlist that is supported by yt-dlp or youtube-dl.
"""
try:
ytcc.add_playlist(name, url, reverse)
except BadURLException as bad_url:
logger.error("The given URL does not point to a playlist or is not supported by "
"youtube-dl")
logger.error("The given URL does not point to a playlist or is not supported")
raise Exit(1) from bad_url
except NameConflictError as name_conflict:
logger.error("The given name is already used for another playlist "
Expand Down
13 changes: 6 additions & 7 deletions ytcc/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def play_video(video: Video, audio_only: bool = False) -> bool:
@staticmethod
def download_video(video: MappedVideo, path: str = "", audio_only: bool = False,
subdirs: Optional[bool] = None) -> bool:
"""Download the given video with youtube-dl.
"""Download the given video.
If the path is not given, the path is read from the config file.
Expand Down Expand Up @@ -242,7 +242,7 @@ def report_progress(self, *args, **kwargs):

ydl.process_ie_result(info, download=True)
except youtube_dl.utils.YoutubeDLError as ydl_err:
logger.debug("youtube-dl failed with '%s'", ydl_err)
logger.debug("Download failed with '%s'", ydl_err)
return False

actual_file = Path(filename_processor.actual_file).expanduser()
Expand Down Expand Up @@ -322,12 +322,12 @@ def add_playlist(self, name: str, url: str, reverse: bool = False,
info = ydl.extract_info(url, download=False, process=True)
except youtube_dl.utils.DownloadError as download_error:
logger.debug(
"'%s' is not supported by youtube-dl. Youtube-dl's error: '%s'",
"'%s' is not supported. Encountered error: '%s'",
url,
download_error
)
raise BadURLException(
"URL is not supported by youtube-dl or does not exist"
"URL is not supported or does not exist"
) from download_error

if info.get("_type") != "playlist":
Expand All @@ -336,7 +336,7 @@ def add_playlist(self, name: str, url: str, reverse: bool = False,
url,
info
)
raise BadURLException("Not a playlist or not supported by youtube-dl")
raise BadURLException("Not a playlist or not supported")

peek = list(info.get("entries"))
for entry in peek:
Expand Down Expand Up @@ -495,7 +495,6 @@ def _bulk_subscribe(self, subscriptions: Iterable[Tuple[str, str]]) -> None:
except NameConflictError:
logger.warning("Ignoring playlist '%s', because it already subscribed", name)
except BadURLException:
logger.warning("Ignoring playlist '%s', "
"because it is not supported by youtube-dl", name)
logger.warning("Ignoring playlist '%s', because it is not supported", name)
else:
logger.info("Added playlist '%s'", name)
4 changes: 2 additions & 2 deletions ytcc/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def get_unprocessed_entries(self, playlist: Playlist) -> Iterable[Tuple[st
info = await loop.run_in_executor(None, partial(ydl.extract_info, playlist.url,
download=False, process=False))
except youtube_dl.DownloadError as download_error:
logging.error("Failed to get playlist %s. Youtube-dl said: '%s'",
logging.error("Failed to get playlist %s. Error was: '%s'",
playlist.name, download_error)
else:
entries = info.get("entries", [])
Expand Down Expand Up @@ -106,7 +106,7 @@ async def process_entry(self, e_hash: str, entry: Any) -> Tuple[str, Optional[Vi
loop = asyncio.get_event_loop()
processed = await loop.run_in_executor(None, self._process_ie, entry)
except youtube_dl.DownloadError as download_error:
logging.warning("Failed to get a video. Youtube-dl said: '%s'", download_error)
logging.warning("Failed to get a video. Error was: '%s'", download_error)
return e_hash, None
else:
title = processed.get("title")
Expand Down

0 comments on commit 14cbf5b

Please sign in to comment.