use of org.schabi.newpipe.database.stream.model.StreamEntity in project NewPipe by TeamNewPipe.
the class StreamDAO method upsertAll.
@Transaction
public List<Long> upsertAll(List<StreamEntity> streams) {
silentInsertAllInternal(streams);
final List<Long> streamIds = new ArrayList<>(streams.size());
for (StreamEntity stream : streams) {
final Long streamId = getStreamIdInternal(stream.getServiceId(), stream.getUrl());
if (streamId == null) {
throw new IllegalStateException("StreamID cannot be null just after insertion.");
}
streamIds.add(streamId);
stream.setUid(streamId);
}
update(streams);
return streamIds;
}
use of org.schabi.newpipe.database.stream.model.StreamEntity in project NewPipe by TeamNewPipe.
the class PlaylistAppendDialog method fromStreamInfoItems.
public static PlaylistAppendDialog fromStreamInfoItems(final List<StreamInfoItem> items) {
PlaylistAppendDialog dialog = new PlaylistAppendDialog();
List<StreamEntity> entities = new ArrayList<>(items.size());
for (final StreamInfoItem item : items) {
entities.add(new StreamEntity(item));
}
dialog.setInfo(entities);
return dialog;
}
use of org.schabi.newpipe.database.stream.model.StreamEntity in project NewPipe by TeamNewPipe.
the class PlaylistAppendDialog method fromPlayQueueItems.
public static PlaylistAppendDialog fromPlayQueueItems(final List<PlayQueueItem> items) {
PlaylistAppendDialog dialog = new PlaylistAppendDialog();
List<StreamEntity> entities = new ArrayList<>(items.size());
for (final PlayQueueItem item : items) {
entities.add(new StreamEntity(item));
}
dialog.setInfo(entities);
return dialog;
}
use of org.schabi.newpipe.database.stream.model.StreamEntity in project NewPipe by TeamNewPipe.
the class HistoryRecordManager method onViewed.
// /////////////////////////////////////////////////////
// Watch History
// /////////////////////////////////////////////////////
public Maybe<Long> onViewed(final StreamInfo info) {
if (!isStreamHistoryEnabled())
return Maybe.empty();
final Date currentTime = new Date();
return Maybe.fromCallable(() -> database.runInTransaction(() -> {
final long streamId = streamTable.upsert(new StreamEntity(info));
StreamHistoryEntity latestEntry = streamHistoryTable.getLatestEntry();
if (latestEntry != null && latestEntry.getStreamUid() == streamId) {
streamHistoryTable.delete(latestEntry);
latestEntry.setAccessDate(currentTime);
latestEntry.setRepeatCount(latestEntry.getRepeatCount() + 1);
return streamHistoryTable.insert(latestEntry);
} else {
return streamHistoryTable.insert(new StreamHistoryEntity(streamId, currentTime));
}
})).subscribeOn(Schedulers.io());
}
use of org.schabi.newpipe.database.stream.model.StreamEntity in project NewPipe by TeamNewPipe.
the class LocalPlaylistManager method createPlaylist.
public Maybe<List<Long>> createPlaylist(final String name, final List<StreamEntity> streams) {
// Disallow creation of empty playlists
if (streams.isEmpty())
return Maybe.empty();
final StreamEntity defaultStream = streams.get(0);
final PlaylistEntity newPlaylist = new PlaylistEntity(name, defaultStream.getThumbnailUrl());
return Maybe.fromCallable(() -> database.runInTransaction(() -> upsertStreams(playlistTable.insert(newPlaylist), streams, 0))).subscribeOn(Schedulers.io());
}
Aggregations