Merge pull request #857 from FireMasterK/video-title

Get original untranslated title for YouTube
This commit is contained in:
Stypox 2022-07-06 10:26:45 +02:00 committed by GitHub
commit 5ab74b3631
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 7 deletions

View File

@ -162,16 +162,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");