Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get original untranslated title for YouTube #857

Merged
merged 1 commit into from
Jul 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,17 @@ public YoutubeStreamExtractor(final StreamingService service, final LinkHandler
@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");
Expand Down