-
Notifications
You must be signed in to change notification settings - Fork 375
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
base: dev
Are you sure you want to change the base?
Conversation
5c3115b
to
534e2a3
Compare
There was a problem hiding this 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
public Duration getDuration() { | ||
return duration; | ||
} | ||
|
||
public void setDuration(final long duration) { | ||
public long getDurationInSeconds() { | ||
return duration.toSeconds(); | ||
} | ||
|
||
public void setDuration(final Duration duration) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
@Nonnull | ||
default Duration getDuration() throws ParsingException { | ||
return Duration.ZERO; | ||
} |
There was a problem hiding this comment.
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.
if (duration.isZero()) { | ||
throw new ParsingException("Could not parse duration \"" + textualDuration + "\""); | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 👍
extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java
Show resolved
Hide resolved
@@ -76,11 +78,15 @@ public void setViewCount(final long viewCount) { | |||
this.viewCount = viewCount; | |||
} | |||
|
|||
public long getDuration() { | |||
public Duration getDuration() { |
There was a problem hiding this comment.
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
Extract stream lengths as
Duration
values.Duration
provides convenience methods for converting to/from different time units, e.g. seconds, hours, etc.long getDuration()
->@Nonnull Duration getDuration()
void setDuration(final long duration)
->void setDuration(@Nonnull final Duration duration)
long getDuration()
->@Nonnull Duration getDuration()