Accept YouTube Music playlists but not YouTube Mixes

This commit is contained in:
TobiGr 2020-03-25 22:23:53 +01:00
parent bff595c6c6
commit 647e7cd450
2 changed files with 9 additions and 1 deletions

View File

@ -45,6 +45,11 @@ public class YoutubePlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
throw new ParsingException("the list-ID given in the URL does not match the list pattern");
}
// Don't accept auto-generated "Mix" playlists but auto-generated YouTube Music playlists
if (listID.startsWith("RD") && !listID.startsWith("RDCLAK")) {
throw new ParsingException("YouTube Mix playlists are not yet supported");
}
return listID;
} catch (final Exception exception) {
throw new ParsingException("Error could not parse url :" + exception.getMessage(), exception);
@ -54,9 +59,10 @@ public class YoutubePlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
@Override
public boolean onAcceptUrl(final String url) {
try {
return !getId(url).startsWith("RD"); // Don't accept auto-generated "Mix" playlists
getId(url);
} catch (ParsingException e) {
return false;
}
return true;
}
}

View File

@ -55,6 +55,8 @@ public class YoutubePlaylistLinkHandlerFactoryTest {
assertTrue(linkHandler.acceptUrl("www.youtube.com/playlist?list=PLW5y1tjAOzI3orQNF1yGGVL5x-pR2K1dC"));
assertTrue(linkHandler.acceptUrl("www.youtube.com/playlist?list=PLz8YL4HVC87WJQDzVoY943URKQCsHS9XV"));
assertTrue(linkHandler.acceptUrl("https://music.youtube.com/playlist?list=OLAK5uy_lEBUW9iTwqf0IlYPxZ8LrzpgqjAHZgZpM"));
assertTrue(linkHandler.acceptUrl("https://www.youtube.com/playlist?list=RDCLAK5uy_ly6s4irLuZAcjEDwJmqcA_UtSipMyGgbQ")); // YouTube Music playlist
assertFalse(linkHandler.acceptUrl("https://www.youtube.com/watch?v=2kZVEUGLgy4&list=RDdoEcQv1wlsI&index=2, ")); // YouTube Mix
}
@Test