Skip to content

Commit 7e0ee4e

Browse files
committed
Update Extractor and add migration to remove SoundCloud Top 50 kiosk
1 parent 938265d commit 7e0ee4e

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ dependencies {
214214
// the corresponding commit hash, since JitPack sometimes deletes artifacts.
215215
// If there’s already a git hash, just add more of it to the end (or remove a letter)
216216
// to cause jitpack to regenerate the artifact.
217-
implementation 'com.github.TeamNewPipe:NewPipeExtractor:68b4c9acbae2d167e7b1209bb6bf0ae086dd427e'
217+
implementation 'com.github.TeamNewPipe:NewPipeExtractor:7adbc48a0aa872c016b8ec089e278d5e12772054'
218218
implementation 'com.github.TeamNewPipe:NoNonsense-FilePicker:5.0.0'
219219

220220
/** Checkstyle **/

app/src/main/java/org/schabi/newpipe/settings/SettingMigrations.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@
1212
import org.schabi.newpipe.error.ErrorInfo;
1313
import org.schabi.newpipe.error.ErrorUtil;
1414
import org.schabi.newpipe.error.UserAction;
15+
import org.schabi.newpipe.extractor.ServiceList;
16+
import org.schabi.newpipe.settings.tabs.Tab;
17+
import org.schabi.newpipe.settings.tabs.TabsManager;
1518
import org.schabi.newpipe.util.DeviceUtils;
1619

1720
import java.util.Collections;
1821
import java.util.HashSet;
22+
import java.util.List;
1923
import java.util.Set;
24+
import java.util.stream.Collectors;
2025

2126
import static org.schabi.newpipe.MainActivity.DEBUG;
27+
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
2228

2329
/**
2430
* In order to add a migration, follow these steps, given P is the previous version:<br>
@@ -129,7 +135,7 @@ protected void migrate(@NonNull final Context context) {
129135
}
130136
};
131137

132-
public static final Migration MIGRATION_5_6 = new Migration(5, 6) {
138+
private static final Migration MIGRATION_5_6 = new Migration(5, 6) {
133139
@Override
134140
protected void migrate(@NonNull final Context context) {
135141
final boolean loadImages = sp.getBoolean("download_thumbnail_key", true);
@@ -143,6 +149,24 @@ protected void migrate(@NonNull final Context context) {
143149
}
144150
};
145151

152+
private static final Migration MIGRATION_6_7 = new Migration(6, 7) {
153+
@Override
154+
protected void migrate(@NonNull final Context context) {
155+
// The SoundCloud Top 50 Kiosk was removed in the extractor,
156+
// so we remove the corresponding tab if it exists.
157+
final TabsManager tabsManager = TabsManager.getManager(context);
158+
final List<Tab> tabs = tabsManager.getTabs();
159+
final List<Tab> cleanedTabs = tabs.stream()
160+
.filter(tab -> !(tab instanceof Tab.KioskTab kioskTab
161+
&& kioskTab.getKioskServiceId() == SoundCloud.getServiceId()
162+
&& kioskTab.getKioskId().equals("Top 50")))
163+
.collect(Collectors.toUnmodifiableList());
164+
if (tabs.size() != cleanedTabs.size()) {
165+
tabsManager.saveTabs(cleanedTabs);
166+
}
167+
}
168+
};
169+
146170
/**
147171
* List of all implemented migrations.
148172
* <p>
@@ -156,12 +180,13 @@ protected void migrate(@NonNull final Context context) {
156180
MIGRATION_3_4,
157181
MIGRATION_4_5,
158182
MIGRATION_5_6,
183+
MIGRATION_6_7
159184
};
160185

161186
/**
162187
* Version number for preferences. Must be incremented every time a migration is necessary.
163188
*/
164-
private static final int VERSION = 6;
189+
private static final int VERSION = 7;
165190

166191

167192
public static void runMigrationsIfNeeded(@NonNull final Context context) {

0 commit comments

Comments
 (0)