Skip to content

Commit 2027b74

Browse files
authored
Merge pull request #6919 from ktprograms/channel-details-all-places
Add Show Channel Details where it's missing
2 parents 3705a1a + 7e27e73 commit 2027b74

16 files changed

Lines changed: 814 additions & 163 deletions

File tree

app/schemas/org.schabi.newpipe.database.AppDatabase/4.json

Lines changed: 713 additions & 0 deletions
Large diffs are not rendered by default.

app/src/androidTest/java/org/schabi/newpipe/database/AppDatabaseTest.kt

Lines changed: 0 additions & 134 deletions
This file was deleted.

app/src/androidTest/java/org/schabi/newpipe/local/playlist/LocalPlaylistManagerTest.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ class LocalPlaylistManagerTest {
4545
fun createPlaylist() {
4646
val stream = StreamEntity(
4747
serviceId = 1, url = "https://newpipe.net/", title = "title",
48-
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader"
48+
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader",
49+
uploaderUrl = "https://newpipe.net/"
4950
)
5051

5152
val result = manager.createPlaylist("name", listOf(stream))
@@ -69,12 +70,14 @@ class LocalPlaylistManagerTest {
6970
fun createPlaylist_nonExistentStreamsAreUpserted() {
7071
val stream = StreamEntity(
7172
serviceId = 1, url = "https://newpipe.net/", title = "title",
72-
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader"
73+
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader",
74+
uploaderUrl = "https://newpipe.net/"
7375
)
7476
database.streamDAO().insert(stream)
7577
val upserted = StreamEntity(
7678
serviceId = 1, url = "https://newpipe.net/2", title = "title2",
77-
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader"
79+
streamType = StreamType.VIDEO_STREAM, duration = 1, uploader = "uploader",
80+
uploaderUrl = "https://newpipe.net/"
7881
)
7982

8083
val result = manager.createPlaylist("name", listOf(stream, upserted))

app/src/main/java/org/schabi/newpipe/NewPipeDatabase.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import static org.schabi.newpipe.database.AppDatabase.DATABASE_NAME;
1212
import static org.schabi.newpipe.database.Migrations.MIGRATION_1_2;
1313
import static org.schabi.newpipe.database.Migrations.MIGRATION_2_3;
14+
import static org.schabi.newpipe.database.Migrations.MIGRATION_3_4;
1415

1516
public final class NewPipeDatabase {
1617
private static volatile AppDatabase databaseInstance;
@@ -22,7 +23,7 @@ private NewPipeDatabase() {
2223
private static AppDatabase getDatabase(final Context context) {
2324
return Room
2425
.databaseBuilder(context.getApplicationContext(), AppDatabase.class, DATABASE_NAME)
25-
.addMigrations(MIGRATION_1_2, MIGRATION_2_3)
26+
.addMigrations(MIGRATION_1_2, MIGRATION_2_3, MIGRATION_3_4)
2627
.build();
2728
}
2829

app/src/main/java/org/schabi/newpipe/database/AppDatabase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.schabi.newpipe.database.subscription.SubscriptionDAO;
2828
import org.schabi.newpipe.database.subscription.SubscriptionEntity;
2929

30-
import static org.schabi.newpipe.database.Migrations.DB_VER_3;
30+
import static org.schabi.newpipe.database.Migrations.DB_VER_4;
3131

3232
@TypeConverters({Converters.class})
3333
@Database(
@@ -38,7 +38,7 @@
3838
FeedEntity.class, FeedGroupEntity.class, FeedGroupSubscriptionEntity.class,
3939
FeedLastUpdatedEntity.class
4040
},
41-
version = DB_VER_3
41+
version = DB_VER_4
4242
)
4343
public abstract class AppDatabase extends RoomDatabase {
4444
public static final String DATABASE_NAME = "newpipe.db";

app/src/main/java/org/schabi/newpipe/database/Migrations.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,19 @@
99
import org.schabi.newpipe.MainActivity;
1010

1111
public final class Migrations {
12+
13+
/////////////////////////////////////////////////////////////////////////////
14+
// Test new migrations manually by importing a database from daily usage //
15+
// and checking if the migration works (Use the Database Inspector //
16+
// https://developer.android.com/studio/inspect/database). //
17+
// If you add a migration point it out in the pull request, so that //
18+
// others remember to test it themselves. //
19+
/////////////////////////////////////////////////////////////////////////////
20+
1221
public static final int DB_VER_1 = 1;
1322
public static final int DB_VER_2 = 2;
1423
public static final int DB_VER_3 = 3;
24+
public static final int DB_VER_4 = 4;
1525

1626
private static final String TAG = Migrations.class.getName();
1727
public static final boolean DEBUG = MainActivity.DEBUG;
@@ -160,5 +170,14 @@ public void migrate(@NonNull final SupportSQLiteDatabase database) {
160170
}
161171
};
162172

173+
public static final Migration MIGRATION_3_4 = new Migration(DB_VER_3, DB_VER_4) {
174+
@Override
175+
public void migrate(@NonNull final SupportSQLiteDatabase database) {
176+
database.execSQL(
177+
"ALTER TABLE streams ADD COLUMN uploader_url TEXT"
178+
);
179+
}
180+
};
181+
163182
private Migrations() { }
164183
}

app/src/main/java/org/schabi/newpipe/database/playlist/PlaylistStreamEntry.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ data class PlaylistStreamEntry(
2727
val item = StreamInfoItem(streamEntity.serviceId, streamEntity.url, streamEntity.title, streamEntity.streamType)
2828
item.duration = streamEntity.duration
2929
item.uploaderName = streamEntity.uploader
30+
item.uploaderUrl = streamEntity.uploaderUrl
3031
item.thumbnailUrl = streamEntity.thumbnailUrl
3132

3233
return item

app/src/main/java/org/schabi/newpipe/database/stream/StreamStatisticsEntry.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class StreamStatisticsEntry(
2929
val item = StreamInfoItem(streamEntity.serviceId, streamEntity.url, streamEntity.title, streamEntity.streamType)
3030
item.duration = streamEntity.duration
3131
item.uploaderName = streamEntity.uploader
32+
item.uploaderUrl = streamEntity.uploaderUrl
3233
item.thumbnailUrl = streamEntity.thumbnailUrl
3334

3435
return item

app/src/main/java/org/schabi/newpipe/database/stream/dao/StreamDAO.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import androidx.room.Insert
66
import androidx.room.OnConflictStrategy
77
import androidx.room.Query
88
import androidx.room.Transaction
9+
import io.reactivex.rxjava3.core.Completable
910
import io.reactivex.rxjava3.core.Flowable
1011
import org.schabi.newpipe.database.BasicDAO
1112
import org.schabi.newpipe.database.stream.model.StreamEntity
@@ -29,6 +30,9 @@ abstract class StreamDAO : BasicDAO<StreamEntity> {
2930
@Query("SELECT * FROM streams WHERE url = :url AND service_id = :serviceId")
3031
abstract fun getStream(serviceId: Long, url: String): Flowable<List<StreamEntity>>
3132

33+
@Query("UPDATE streams SET uploader_url = :uploaderUrl WHERE url = :url AND service_id = :serviceId")
34+
abstract fun setUploaderUrl(serviceId: Long, url: String, uploaderUrl: String): Completable
35+
3236
@Insert(onConflict = OnConflictStrategy.IGNORE)
3337
internal abstract fun silentInsertInternal(stream: StreamEntity): Long
3438

app/src/main/java/org/schabi/newpipe/database/stream/model/StreamEntity.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ data class StreamEntity(
4545
@ColumnInfo(name = STREAM_UPLOADER)
4646
var uploader: String,
4747

48+
@ColumnInfo(name = STREAM_UPLOADER_URL)
49+
var uploaderUrl: String? = null,
50+
4851
@ColumnInfo(name = STREAM_THUMBNAIL_URL)
4952
var thumbnailUrl: String? = null,
5053

@@ -64,7 +67,7 @@ data class StreamEntity(
6467
constructor(item: StreamInfoItem) : this(
6568
serviceId = item.serviceId, url = item.url, title = item.name,
6669
streamType = item.streamType, duration = item.duration, uploader = item.uploaderName,
67-
thumbnailUrl = item.thumbnailUrl, viewCount = item.viewCount,
70+
uploaderUrl = item.uploaderUrl, thumbnailUrl = item.thumbnailUrl, viewCount = item.viewCount,
6871
textualUploadDate = item.textualUploadDate, uploadDate = item.uploadDate?.offsetDateTime(),
6972
isUploadDateApproximation = item.uploadDate?.isApproximation
7073
)
@@ -73,7 +76,7 @@ data class StreamEntity(
7376
constructor(info: StreamInfo) : this(
7477
serviceId = info.serviceId, url = info.url, title = info.name,
7578
streamType = info.streamType, duration = info.duration, uploader = info.uploaderName,
76-
thumbnailUrl = info.thumbnailUrl, viewCount = info.viewCount,
79+
uploaderUrl = info.uploaderUrl, thumbnailUrl = info.thumbnailUrl, viewCount = info.viewCount,
7780
textualUploadDate = info.textualUploadDate, uploadDate = info.uploadDate?.offsetDateTime(),
7881
isUploadDateApproximation = info.uploadDate?.isApproximation
7982
)
@@ -82,13 +85,14 @@ data class StreamEntity(
8285
constructor(item: PlayQueueItem) : this(
8386
serviceId = item.serviceId, url = item.url, title = item.title,
8487
streamType = item.streamType, duration = item.duration, uploader = item.uploader,
85-
thumbnailUrl = item.thumbnailUrl
88+
uploaderUrl = item.uploaderUrl, thumbnailUrl = item.thumbnailUrl
8689
)
8790

8891
fun toStreamInfoItem(): StreamInfoItem {
8992
val item = StreamInfoItem(serviceId, url, title, streamType)
9093
item.duration = duration
9194
item.uploaderName = uploader
95+
item.uploaderUrl = uploaderUrl
9296
item.thumbnailUrl = thumbnailUrl
9397

9498
if (viewCount != null) item.viewCount = viewCount as Long
@@ -109,6 +113,7 @@ data class StreamEntity(
109113
const val STREAM_TYPE = "stream_type"
110114
const val STREAM_DURATION = "duration"
111115
const val STREAM_UPLOADER = "uploader"
116+
const val STREAM_UPLOADER_URL = "uploader_url"
112117
const val STREAM_THUMBNAIL_URL = "thumbnail_url"
113118

114119
const val STREAM_VIEWS = "view_count"

0 commit comments

Comments
 (0)