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

[YouTube] Improve duration parsing #971

Merged
merged 1 commit into from
Nov 16, 2022
Merged

[YouTube] Improve duration parsing #971

merged 1 commit into from
Nov 16, 2022

Conversation

lrusso96
Copy link
Contributor

@lrusso96 lrusso96 commented Nov 9, 2022

  • I carefully read the contribution guidelines and agree to them.
  • I have tested the API against NewPipe.
  • I agree to create a pull request for NewPipe as soon as possible to make it compatible with the changed API.

(No API change tho)

I have simplified ad optimized the code to parse the duration of YouTube videos.
In the previous version, the parsing method parseDurationString was a bit redundant, making some extra (useless) method calls for short videos.
In particular, there were calls to "sanitize" and check the "0" strings, added within the method.
This code is not only more compact, but only makes the necessary calls to convertDurationToInt: e.g., for short videos (<1h), this approach seems twice faster on my device(s).

Copy link
Member

@Redirion Redirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. I like it. Like a small puzzle that you have solved with the offset.

@TobiGr TobiGr added youtube service, https://www.youtube.com/ codequality Improvements to the codebase to improve the code quality labels Nov 9, 2022
Copy link

@acrodemocide acrodemocide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider changing the if statement commented on to preserve the logic being replaced for the case statement.

Copy link

@acrodemocide acrodemocide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment resolved

@TobiGr TobiGr merged commit 2211a24 into TeamNewPipe:dev Nov 16, 2022
@lrusso96 lrusso96 deleted the patch-1 branch November 16, 2022 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codequality Improvements to the codebase to improve the code quality youtube service, https://www.youtube.com/
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants