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

Obtain stream length as a Duration #1106

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Isira-Seneviratne
Copy link
Member

@Isira-Seneviratne Isira-Seneviratne commented Sep 18, 2023

Extract stream lengths as Duration values. Duration provides convenience methods for converting to/from different time units, e.g. seconds, hours, etc.

⚠️ Breaking Changes

  • StreamInfoItem:
    • long getDuration() -> @Nonnull Duration getDuration()
    • void setDuration(final long duration) -> void setDuration(@Nonnull final Duration duration)
  • StreamInfoItemExtractor:
    • long getDuration() -> @Nonnull Duration getDuration()

  • 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.

@TobiGr TobiGr added the codequality Improvements to the codebase to improve the code quality label Sep 18, 2023
Copy link
Collaborator

@XiangRongLin XiangRongLin left a comment

Choose a reason for hiding this comment

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

I don't know what the policy around breaking changes is anymore, otherwise it looks fine. But it should be at least mentioned that its a breaking change in the PR itself

Comment on lines +81 to +89
public Duration getDuration() {
return duration;
}

public void setDuration(final long duration) {
public long getDurationInSeconds() {
return duration.toSeconds();
}

public void setDuration(final Duration duration) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I want to note that this is a breaking change. So the app will need to be adjusted accordingly

Copy link
Member

Choose a reason for hiding this comment

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

Param should be annotated as @Nonnull

Comment on lines +58 to +61
@Nonnull
default Duration getDuration() throws ParsingException {
return Duration.ZERO;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This could also be a breaking change.

Comment on lines +95 to +97
if (duration.isZero()) {
throw new ParsingException("Could not parse duration \"" + textualDuration + "\"");
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can't duration not be uninitialized at the start and if it is still not initialized then throw the exception

Copy link
Member

Choose a reason for hiding this comment

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

Yes, setting duration to null is a better approach here 👍

@@ -76,11 +78,15 @@ public void setViewCount(final long viewCount) {
this.viewCount = viewCount;
}

public long getDuration() {
public Duration getDuration() {
Copy link
Member

Choose a reason for hiding this comment

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

Should be annotated as @Nonnull

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants