Fix timestamp links in Youtube video descriptions#188
Merged
theScrabi merged 1 commit intoTeamNewPipe:devfrom Aug 22, 2019
Merged
Fix timestamp links in Youtube video descriptions#188theScrabi merged 1 commit intoTeamNewPipe:devfrom
theScrabi merged 1 commit intoTeamNewPipe:devfrom
Conversation
For some reason, in NewPipeExtractor, comments were loaded from JSON by YoutubeCommentsInfoItemExtractor as text, sent via CommentsInfoItem#getCommentText to NewPipe, where timestamps are converted to hyperlinks using Linkify: TeamNewPipe/NewPipe#2168 On the other hand, video descriptions are handled in NewPipeExtractor by scraping the watch-page HTML. There, timestamp links were previously mangled (and now properly parsed), before being sent as HTML via YoutubeStreamExtractor#getDescription to NewPipe (where HTML gets converted to Spanned). The logic introduced in this commit is different from the above PR, since it operates in the extractor, and mutates the HTML DOM rather than identifying via regex.
1 task
Member
|
This fixes TeamNewPipe/NewPipe#1025, doesn't it? Add |
Contributor
Author
|
Thanks for merging! Possibly you still need to merge TeamNewPipe/NewPipe#2536, otherwise |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an issue where timestamps in video descriptions have their text and destination replaced with
...video?v=...#. This PR changes those links to point to...video?v=...&t=timestampbut keeps the text unchanged. This causes NewPipe to play the video starting from the correct time.This code handles both mm:ss and hh:mm:ss links (since :ss links are not made into clickable
<a>by Youtube). Test case: https://www.youtube.com/watch?v=4cccfDXu1vAFor some reason, in NewPipeExtractor, comments were loaded from JSON by YoutubeCommentsInfoItemExtractor as text, sent via CommentsInfoItem#getCommentText to NewPipe, where timestamps are converted to hyperlinks using Linkify:
TeamNewPipe/NewPipe#2168
On the other hand, video descriptions are handled in NewPipeExtractor by scraping the watch-page HTML. There, timestamp links were previously mangled (and now properly parsed), before being sent as HTML via YoutubeStreamExtractor#getDescription to NewPipe (where HTML gets converted to Spanned).
The logic introduced in this commit is different from the above PR, since it operates in the extractor, and mutates the HTML DOM rather than identifying via regex. It makes more sense to put timestamp link conversion here, alongside converting other types of links, and to prevent the other if-statements here from mangling the links.
The code formatting and syntax may be unconventional (especially
(onClickTimestamp = DESCRIPTION_TIMESTAMP_ONCLICK_REGEX.matcher(a.attr("onclick"))).find()). Maybe the variable names aren't the best.No unit tests added yet :(
Fixes TeamNewPipe/NewPipe#1025.