[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

View File

@ -232,19 +232,9 @@ public class YoutubeMixPlaylistExtractor extends PlaylistExtractor {
} }
@Nonnull @Nonnull
private String getThumbnailUrlFromPlaylistId(@Nonnull final String playlistId) throws ParsingException { private String getThumbnailUrlFromPlaylistId(@Nonnull final String playlistId)
final String videoId; throws ParsingException {
if (isYoutubeMyMixId(playlistId)) { return getThumbnailUrlFromVideoId(YoutubeParsingHelper.extractVideoIdFromMixId(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);
} }
@Nonnull @Nonnull