Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Stypox committed Jul 5, 2022
2 parents 81369d7 + 5ac71e0 commit d81607c
Show file tree
Hide file tree
Showing 48 changed files with 697 additions and 233 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
resValue "string", "app_name", "NewPipe"
minSdk 19
targetSdk 29
versionCode 986
versionName "0.23.0"
versionCode 987
versionName "0.23.1"

multiDexEnabled true

Expand Down Expand Up @@ -190,7 +190,7 @@ dependencies {
// name and the commit hash with the commit hash of the (pushed) commit you want to test
// This works thanks to JitPack: https://jitpack.io/
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:a26bcc55c47f169e21c994f28b22f8edcb6f19bf'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:5219a705bab539cf8c6624d0cec216e76e85f0b1'

/** Checkstyle **/
checkstyle "com.puppycrawl.tools:checkstyle:${checkstyleVersion}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.ForeignKey;
import androidx.room.Ignore;
import androidx.room.Index;

import org.schabi.newpipe.database.stream.model.StreamEntity;
Expand Down Expand Up @@ -42,18 +41,19 @@ public class StreamHistoryEntity {
@ColumnInfo(name = STREAM_REPEAT_COUNT)
private long repeatCount;

public StreamHistoryEntity(final long streamUid, @NonNull final OffsetDateTime accessDate,
/**
* @param streamUid the stream id this history item will refer to
* @param accessDate the last time the stream was accessed
* @param repeatCount the total number of views this stream received
*/
public StreamHistoryEntity(final long streamUid,
@NonNull final OffsetDateTime accessDate,
final long repeatCount) {
this.streamUid = streamUid;
this.accessDate = accessDate;
this.repeatCount = repeatCount;
}

@Ignore
public StreamHistoryEntity(final long streamUid, @NonNull final OffsetDateTime accessDate) {
this(streamUid, accessDate, 0); // start with 0 views (adding views will be done elsewhere)
}

public long getStreamUid() {
return streamUid;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,11 @@ public Maybe<Long> markAsWatched(final StreamInfoItem info) {

// Add a history entry
final StreamHistoryEntity latestEntry = streamHistoryTable.getLatestEntry(streamId);
if (latestEntry != null) {
streamHistoryTable.delete(latestEntry);
latestEntry.setAccessDate(currentTime);
latestEntry.setRepeatCount(latestEntry.getRepeatCount() + 1);
return streamHistoryTable.insert(latestEntry);
if (latestEntry == null) {
// never actually viewed: add history entry but with 0 views
return streamHistoryTable.insert(new StreamHistoryEntity(streamId, currentTime, 0));
} else {
return streamHistoryTable.insert(new StreamHistoryEntity(streamId, currentTime));
return 0L;
}
})).subscribeOn(Schedulers.io());
}
Expand All @@ -155,7 +153,8 @@ public Maybe<Long> onViewed(final StreamInfo info) {
latestEntry.setRepeatCount(latestEntry.getRepeatCount() + 1);
return streamHistoryTable.insert(latestEntry);
} else {
return streamHistoryTable.insert(new StreamHistoryEntity(streamId, currentTime));
// just viewed for the first time: set 1 view
return streamHistoryTable.insert(new StreamHistoryEntity(streamId, currentTime, 1));
}
})).subscribeOn(Schedulers.io());
}
Expand Down
23 changes: 16 additions & 7 deletions app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -2485,22 +2485,31 @@ public void onEvents(@NonNull final com.google.android.exoplayer2.Player player,
Listener.super.onEvents(player, events);
MediaItemTag.from(player.getCurrentMediaItem()).ifPresent(tag -> {
if (tag == currentMetadata) {
return;
return; // we still have the same metadata, no need to do anything
}
final StreamInfo previousInfo = Optional.ofNullable(currentMetadata)
.flatMap(MediaItemTag::getMaybeStreamInfo).orElse(null);
currentMetadata = tag;
if (!tag.getErrors().isEmpty()) {

if (!currentMetadata.getErrors().isEmpty()) {
// new errors might have been added even if previousInfo == tag.getMaybeStreamInfo()
final ErrorInfo errorInfo = new ErrorInfo(
tag.getErrors().get(0),
currentMetadata.getErrors(),
UserAction.PLAY_STREAM,
"Loading failed for [" + tag.getTitle() + "]: " + tag.getStreamUrl(),
tag.getServiceId());
"Loading failed for [" + currentMetadata.getTitle()
+ "]: " + currentMetadata.getStreamUrl(),
currentMetadata.getServiceId());
ErrorUtil.createNotification(context, errorInfo);
}
tag.getMaybeStreamInfo().ifPresent(info -> {

currentMetadata.getMaybeStreamInfo().ifPresent(info -> {
if (DEBUG) {
Log.d(TAG, "ExoPlayer - onEvents() update stream info: " + info.getName());
}
updateMetadataWith(info);
if (previousInfo == null || !previousInfo.getUrl().equals(info.getUrl())) {
// only update with the new stream info if it has actually changed
updateMetadataWith(info);
}
});
});
}
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -762,4 +762,12 @@
</plurals>
<string name="percent">النسبة المئوية</string>
<string name="semitone">سيميتون</string>
<string name="streams_not_yet_supported_removed">لا يتم عرض التدفقات التي لم يدعمها برنامج التنزيل بعد</string>
<string name="selected_stream_external_player_not_supported">الدفق المحدد غير مدعوم من قبل المشغلون الخارجيون</string>
<string name="no_audio_streams_available_for_external_players">لا توجد تدفقات صوتية متاحة للمشغلات الخارجية</string>
<string name="no_video_streams_available_for_external_players">لا تتوفر تدفقات فيديو للاعبين الخارجيين</string>
<string name="select_quality_external_players">حدد الجودة للمشغلين الخارجيين</string>
<string name="unknown_format">تنسيق غير معروف</string>
<string name="unknown_quality">جودة غير معروفة</string>
<string name="progressive_load_interval_title">حجم الفاصل الزمني لتحميل التشغيل</string>
</resources>
Loading

0 comments on commit d81607c

Please sign in to comment.