[YouTube] Deduplicate code extracting video id from mix id

This commit is contained in:
Stypox 2022-02-17 17:07:26 +01:00
parent 8f9d5b858e
commit f19660e7d9
No known key found for this signature in database
GPG Key ID: 4BDF1B40A49FDD23
1 changed files with 3 additions and 13 deletions

View File

@ -232,19 +232,9 @@ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor {
}
@Nonnull
private String getThumbnailUrlFromPlaylistId(@Nonnull final String playlistId) throws ParsingException {
final String videoId;
if (isYoutubeMyMixId(playlistId)) {
videoId = playlistId.substring(4);
} else if (isYoutubeChannelMixId(playlistId)) {
throw new ParsingException("This playlist is a channel mix");
} else {
videoId = playlistId.substring(2);
}
if (videoId.isEmpty()) {
throw new ParsingException("videoId is empty");
}
return getThumbnailUrlFromVideoId(videoId);
private String getThumbnailUrlFromPlaylistId(@Nonnull final String playlistId)
throws ParsingException {
return getThumbnailUrlFromVideoId(YoutubeParsingHelper.extractVideoIdFromMixId(playlistId));
}
@Nonnull