Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check YouTube playlists for unplayable videos while queuing them #1230

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ag-av
Copy link

@ag-av ag-av commented Feb 23, 2025

This PR avoids crashes while playing YouTube playlists with unplayable videos in them. The errors I got looked like this:

/usr/app/node_modules/@distube/ytdl-core/lib/utils.js:174
    return new UnrecoverableError(playability.reason || "This video is unavailable.");
           ^

UnrecoverableError: Video unavailable
    at exports.playError (/usr/app/node_modules/@distube/ytdl-core/lib/utils.js:174:12)
    at exports.getBasicInfo (/usr/app/node_modules/@distube/ytdl-core/lib/info.js:43:25)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The playlist items are checked for deleted and private videos first and the region restrictions of the remaining ones after that. To be able to check if the video ist blocked in the current country the new environment variable IP_COUNTRY_CODE must be set to the country code of the servers IP (added a note for it to the README). If unplayable videos were detected, the bot sends a new message before the Now Playing message, which lists them by their playlist index (starting at 1) and looks something like this:

Found Unplayable Songs
Found 3 unplayable songs in the playlist:

  • 5 - private
  • 8 - unspecified status (probably deleted)
  • 56 - region restricted [Song Name]

Indices of the songs in the playlist and their privacy status.

I also started to integrate the region restriction checks to the single video querying, but for some odd reason it's not a problem there. While the Video unavailable error was thrown for blocked videos in playlists, they are playing just fine when adding them on their own. Thats the reason behind the comment at src/services/youtube-api.ts:124.

@codetheweb
Copy link
Collaborator

📦 🤖 A new release has been made for this pull request.

To play around with this PR, pull ghcr.io/museofficial/muse:pr-1230.

Images are available for x86_64 and ARM64.

Latest commit: 0b3fce9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants