Get original untranslated title for YouTube.

This commit is contained in:
Kavin 2022-06-02 09:57:52 +01:00
parent 1dc80957d8
commit 7635aeed2c
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD

View file

@ -163,16 +163,17 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override
public String getName() throws ParsingException {
assertPageFetched();
String title = null;
String title;
try {
title = getTextFromObject(getVideoPrimaryInfoRenderer().getObject("title"));
} catch (final ParsingException ignored) {
// Age-restricted videos cause a ParsingException here
}
// Try to get the video's original title, which is untranslated
title = playerResponse.getObject("videoDetails").getString("title");
if (isNullOrEmpty(title)) {
title = playerResponse.getObject("videoDetails").getString("title");
try {
title = getTextFromObject(getVideoPrimaryInfoRenderer().getObject("title"));
} catch (final ParsingException ignored) {
// Age-restricted videos cause a ParsingException here
}
if (isNullOrEmpty(title)) {
throw new ParsingException("Could not get name");