1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-12-23 08:30:44 +00:00

Created the first draft.

This commit is contained in:
Jared Fantaye 2023-01-10 20:55:18 +01:00
parent 1bb166a9e8
commit eb3363d4dd
5 changed files with 44 additions and 0 deletions

View File

@ -83,4 +83,15 @@ public interface PlaylistStreamDAO extends BasicDAO<PlaylistStreamEntity> {
+ " GROUP BY " + JOIN_PLAYLIST_ID + " GROUP BY " + JOIN_PLAYLIST_ID
+ " ORDER BY " + PLAYLIST_NAME + " COLLATE NOCASE ASC") + " ORDER BY " + PLAYLIST_NAME + " COLLATE NOCASE ASC")
Flowable<List<PlaylistMetadataEntry>> getPlaylistMetadata(); Flowable<List<PlaylistMetadataEntry>> getPlaylistMetadata();
@Transaction
@Query("DELETE FROM " + PLAYLIST_STREAM_JOIN_TABLE
+ " WHERE " + JOIN_PLAYLIST_ID + "=:playlistId"
+ " AND " + JOIN_STREAM_ID + " IN ("
+ " SELECT " + JOIN_STREAM_ID
+ " FROM " + PLAYLIST_STREAM_JOIN_TABLE
+ " WHERE " + JOIN_PLAYLIST_ID + "=:playlistId"
+ " GROUP BY " + JOIN_STREAM_ID
+ " HAVING COUNT(*) > 1 )" )
Flowable<List<PlaylistMetadataEntry>> removeDuplicates(long playlistId);
} }

View File

@ -367,6 +367,8 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
.create() .create()
.show(); .show();
} }
} else if (item.getItemId() == R.id.menu_item_remove_duplicates) {
openRemoveDuplicatesDialog();
} else { } else {
return super.onOptionsItemSelected(item); return super.onOptionsItemSelected(item);
} }
@ -621,6 +623,24 @@ public class LocalPlaylistFragment extends BaseLocalListFragment<List<PlaylistSt
changeThumbnailUrl(newThumbnailUrl); changeThumbnailUrl(newThumbnailUrl);
} }
private void openRemoveDuplicatesDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(this.getActivity());
builder.setTitle("R.string.duplicate_stream_in_playlist_title")
.setMessage("test")
.setPositiveButton(android.R.string.yes, (dialog, i) -> {
removeDuplicatesInPlaylist();
})
.setNeutralButton(R.string.cancel, null);
builder.create().show();
}
private void removeDuplicatesInPlaylist() {
}
private void deleteItem(final PlaylistStreamEntry item) { private void deleteItem(final PlaylistStreamEntry item) {
if (itemListAdapter == null) { if (itemListAdapter == null) {
return; return;

View File

@ -86,6 +86,12 @@ public class LocalPlaylistManager {
return playlistStreamTable.getPlaylistMetadata().subscribeOn(Schedulers.io()); return playlistStreamTable.getPlaylistMetadata().subscribeOn(Schedulers.io());
} }
public Flowable<List<PlaylistMetadataEntry>> removeDuplicateStreams() {
// TODO: Delete Duplicates and rebuild the index
// TODO: Rebuild the index
return playlistStreamTable.getPlaylistMetadata().subscribeOn(Schedulers.io());
}
public Flowable<List<PlaylistStreamEntry>> getPlaylistStreams(final long playlistId) { public Flowable<List<PlaylistStreamEntry>> getPlaylistStreams(final long playlistId) {
return playlistStreamTable.getOrderedStreamsOf(playlistId).subscribeOn(Schedulers.io()); return playlistStreamTable.getOrderedStreamsOf(playlistId).subscribeOn(Schedulers.io());
} }

View File

@ -12,8 +12,14 @@
android:id="@+id/menu_item_rename_playlist" android:id="@+id/menu_item_rename_playlist"
android:title="@string/rename_playlist" android:title="@string/rename_playlist"
app:showAsAction="never" /> app:showAsAction="never" />
<item <item
android:id="@+id/menu_item_remove_watched" android:id="@+id/menu_item_remove_watched"
android:title="@string/remove_watched" android:title="@string/remove_watched"
app:showAsAction="never" /> app:showAsAction="never" />
<item
android:id="@+id/menu_item_remove_duplicates"
android:title="@string/remove_duplicates"
app:showAsAction="never" />
</menu> </menu>

View File

@ -626,6 +626,7 @@
<string name="systems_language">System default</string> <string name="systems_language">System default</string>
<string name="remove_watched">Remove watched</string> <string name="remove_watched">Remove watched</string>
<string name="remove_watched_popup_title">Remove watched videos?</string> <string name="remove_watched_popup_title">Remove watched videos?</string>
<string name="remove_duplicates">Remove duplicates</string>
<string name="remove_watched_popup_warning">Videos that have been watched before and after being added to the playlist will be removed. <string name="remove_watched_popup_warning">Videos that have been watched before and after being added to the playlist will be removed.
\nAre you sure\? This cannot be undone!</string> \nAre you sure\? This cannot be undone!</string>
<string name="remove_watched_popup_yes_and_partially_watched_videos">Yes, and partially watched videos</string> <string name="remove_watched_popup_yes_and_partially_watched_videos">Yes, and partially watched videos</string>