Fix removing unwatched streams from playlist when using "remove watched"
The bug is caused by a wanted but forgotten inconsistency in the database. A stream can be listed in the watch history (StreamHistoryEntity) while having no corresponding playback state (StreamStateEntity) containing the matching playback position. This is caused by the fact that NewPipe does not consider a watch time of less than five seconds to be worthy to be put into the StreamStateEntity because the video was most likely played by error. Those videos are, however, counted and stored in the watch history.
This commit is contained in:
parent
03abf7a950
commit
ec87d3e0bc
1 changed files with 20 additions and 31 deletions
|
|
@ -447,33 +447,23 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
.getIsPlaylistThumbnailPermanent(playlistId);
|
.getIsPlaylistThumbnailPermanent(playlistId);
|
||||||
boolean thumbnailVideoRemoved = false;
|
boolean thumbnailVideoRemoved = false;
|
||||||
|
|
||||||
if (removePartiallyWatched) {
|
|
||||||
for (final var playlistItem : playlist) {
|
|
||||||
final int indexInHistory = Collections.binarySearch(historyStreamIds,
|
|
||||||
playlistItem.getStreamId());
|
|
||||||
|
|
||||||
if (indexInHistory < 0) {
|
|
||||||
itemsToKeep.add(playlistItem);
|
|
||||||
} else if (!isThumbnailPermanent && !thumbnailVideoRemoved
|
|
||||||
&& playlistManager.getPlaylistThumbnailStreamId(playlistId)
|
|
||||||
== playlistItem.getStreamEntity().getUid()) {
|
|
||||||
thumbnailVideoRemoved = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
final var streamStates = recordManager
|
final var streamStates = recordManager
|
||||||
.loadLocalStreamStateBatch(playlist).blockingGet();
|
.loadLocalStreamStateBatch(playlist).blockingGet();
|
||||||
|
|
||||||
for (int i = 0; i < playlist.size(); i++) {
|
for (int i = 0; i < playlist.size(); i++) {
|
||||||
final var playlistItem = playlist.get(i);
|
final var playlistItem = playlist.get(i);
|
||||||
final var streamStateEntity = streamStates.get(i);
|
final var streamStateEntity = streamStates.get(i);
|
||||||
|
|
||||||
final int indexInHistory = Collections.binarySearch(historyStreamIds,
|
final int indexInHistory = Collections.binarySearch(historyStreamIds,
|
||||||
playlistItem.getStreamId());
|
playlistItem.getStreamId());
|
||||||
final long duration = playlistItem.toStreamInfoItem().getDuration();
|
final long duration = playlistItem.toStreamInfoItem().getDuration();
|
||||||
|
|
||||||
if (indexInHistory < 0 || (streamStateEntity != null
|
if (indexInHistory < 0 // stream is not in history
|
||||||
&& !streamStateEntity.isFinished(duration))) {
|
// stream is in history but the streamStateEntity is null
|
||||||
|
// if the stream was played for less than 5 seconds, see
|
||||||
|
// StreamStateEntity#PLAYBACK_SAVE_THRESHOLD_START_MILLISECONDS
|
||||||
|
|| streamStateEntity == null
|
||||||
|
|| (!streamStateEntity.isFinished(duration)
|
||||||
|
&& !removePartiallyWatched)) {
|
||||||
itemsToKeep.add(playlistItem);
|
itemsToKeep.add(playlistItem);
|
||||||
} else if (!isThumbnailPermanent && !thumbnailVideoRemoved
|
} else if (!isThumbnailPermanent && !thumbnailVideoRemoved
|
||||||
&& playlistManager.getPlaylistThumbnailStreamId(playlistId)
|
&& playlistManager.getPlaylistThumbnailStreamId(playlistId)
|
||||||
|
|
@ -481,7 +471,6 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
|
||||||
thumbnailVideoRemoved = true;
|
thumbnailVideoRemoved = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return new Pair<>(itemsToKeep, thumbnailVideoRemoved);
|
return new Pair<>(itemsToKeep, thumbnailVideoRemoved);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue