File tree Expand file tree Collapse file tree
app/src/main/java/org/schabi/newpipe/local/history Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4444import org .schabi .newpipe .extractor .stream .StreamInfo ;
4545import org .schabi .newpipe .extractor .stream .StreamInfoItem ;
4646import org .schabi .newpipe .player .playqueue .PlayQueueItem ;
47+ import org .schabi .newpipe .util .ExtractorHelper ;
4748
4849import java .time .OffsetDateTime ;
4950import java .time .ZoneOffset ;
@@ -91,16 +92,27 @@ public Maybe<Long> markAsWatched(final StreamInfoItem info) {
9192 return Maybe .fromCallable (() -> database .runInTransaction (() -> {
9293 final long streamId = streamTable .upsert (new StreamEntity (info ));
9394
95+ long duration = info .getDuration ();
96+ if (duration < 0 ) {
97+ duration = ExtractorHelper .getStreamInfo (
98+ info .getServiceId (),
99+ info .getUrl (),
100+ false )
101+ .subscribeOn (Schedulers .io ())
102+ .blockingGet ()
103+ .getDuration ();
104+ }
105+
94106 final List <StreamStateEntity > states = streamStateTable .getState (streamId )
95107 .blockingFirst ();
96108 if (!states .isEmpty ()) {
97109 final StreamStateEntity entity = states .get (0 );
98- entity .setProgressMillis (info . getDuration () * 1000 );
110+ entity .setProgressMillis (duration * 1000 );
99111 streamStateTable .update (entity );
100112 } else {
101113 final StreamStateEntity entity = new StreamStateEntity (
102114 streamId ,
103- info . getDuration () * 1000
115+ duration * 1000
104116 );
105117 streamStateTable .insert (entity );
106118 }
You can’t perform that action at this time.
0 commit comments