Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
213fb35
Add UI for smart download of playlist
VishalNehra Jan 18, 2019
4b07220
Merge branch 'dev' of https://github.com/TeamNewPipe/NewPipe into dow…
VishalNehra Jan 18, 2019
e612142
Fix auto starting download of remaining items when skip is pressed
VishalNehra Jan 18, 2019
7e8674b
Use subscribe instead of blockingGet for auto download
VishalNehra Jan 18, 2019
26a10e9
Sort the videos in "What's New" page by publish date in latest-oldest…
timfbfbfbfb Aug 20, 2019
b142387
Fix app crashes when the subscription list is empty
timfbfbfbfb Aug 22, 2019
920387f
Merge branch 'dev' of github.com:TeamNewPipe/NewPipe into dev
timfbfbfbfb Aug 22, 2019
b707661
Merge branch 'dev' of github.com:TeamNewPipe/NewPipe into dev
timfbfbfbfb Aug 23, 2019
e29982c
Prevent duplication of videos in `What's New` page
timfbfbfbfb Aug 23, 2019
82a004a
Merge dev
Sep 5, 2019
a538078
Fix comments
Sep 8, 2019
5961a4a
Merge branch 'dev' of github.com:TeamNewPipe/NewPipe into dev
timfbfbfbfb Sep 10, 2019
a075f1f
Merge branch 'dev' of github.com:TeamNewPipe/NewPipe into dev
timfbfbfbfb Sep 12, 2019
f39fdfc
Merge branch 'dev' into dev
Stypox Sep 29, 2019
3ab9525
Add error snackbar and javadoc
timfbfbfbfb Sep 30, 2019
6066ee0
Merge branch 'dev' of github.com:TeamNewPipe/NewPipe into dev
timfbfbfbfb Oct 2, 2019
0f3822b
Handle SoundCloud channels in What's new page
timfbfbfbfb Oct 2, 2019
277c8e9
Handle MediaCCC channels in What's new page
timfbfbfbfb Oct 3, 2019
bd2b32b
Fixed Playlists With No Uploader Crashing The App
PeterHindes Oct 14, 2019
3794002
much simpler, "uploader" will never change on a playlist
PeterHindes Oct 14, 2019
cb5c219
Added a restart song button to signle track expanded notification
PeterHindes Oct 14, 2019
646e327
Revert "Added a restart song button to signle track expanded notifica…
PeterHindes Oct 14, 2019
e72c6ee
Explain What we did in the code itself
PeterHindes Oct 14, 2019
c93c52a
Wrap in multiline comment so it colapses
PeterHindes Oct 14, 2019
9fb6ee6
Revert "much simpler, "uploader" will never change on a playlist"
PeterHindes Oct 14, 2019
bc057c1
Revert "Fixed Playlists With No Uploader Crashing The App"
PeterHindes Oct 14, 2019
bfc987f
Revert "Revert "Added a restart song button to signle track expanded …
PeterHindes Oct 15, 2019
fd34b1a
Fixes Improved
PeterHindes Oct 15, 2019
c68c35e
Better FIx, Improved Comment Style
PeterHindes Oct 15, 2019
4106645
Polished Results
PeterHindes Oct 15, 2019
8c73253
follow stye on debug
PeterHindes Oct 15, 2019
f606026
Merge branch 'dev-all-changes' into dev
PeterHindes Oct 15, 2019
c7f2a8f
Merge pull request #3 from PeterHindes/dev
PeterHindes Oct 15, 2019
cc1e5ed
Revert "Merge branch 'dev-all-changes' into dev"
PeterHindes Oct 15, 2019
49db47c
describe what "Auto-Generated" Means
PeterHindes Oct 15, 2019
df2bb22
Much Simpler Fix
PeterHindes Oct 15, 2019
1420fa9
Merge branch 'dev' of github.com:TeamNewPipe/NewPipe into dev
timfbfbfbfb Oct 15, 2019
9c00e7f
Using Strings
PeterHindes Oct 15, 2019
797e1a1
Comment out debuging code
PeterHindes Oct 15, 2019
b12c929
please hold
PeterHindes Oct 15, 2019
ad2de3a
only use TextUtils.equals (fixes more crashes)
PeterHindes Oct 15, 2019
87378fc
Fixed library showing null
PeterHindes Oct 17, 2019
8f46757
New no uploader, still needs a way to programaticly switch
PeterHindes Oct 17, 2019
098302b
Merge pull request #5 from timfbfbfbfb/dev
PeterHindes Oct 17, 2019
d74d157
Merge pull request #6 from PeterHindes/dev
PeterHindes Oct 17, 2019
0704a84
Fix NPE for storage helper when creating new downloadSetting from old…
Oct 19, 2019
6015fbd
Merge dev
Oct 19, 2019
93782c7
Merge branch 'dev' into download-playlist
VishalNehra Oct 21, 2019
9a62f1a
Merge pull request #8 from TeamNewPipe/dev
PeterHindes Oct 28, 2019
ae16d50
Merge pull request #9 from VishalNehra/download-playlist
PeterHindes Oct 28, 2019
15aa27a
Merge branch 'dev-all-changes' into dev-notification-enhancements
PeterHindes Oct 28, 2019
958f6ea
Revert "please hold"
PeterHindes Oct 28, 2019
c38b685
Merge branch 'dev-notification-enhancements' of https://github.com/Pe…
PeterHindes Oct 28, 2019
a5500a7
Fix A Merge Issue
PeterHindes Oct 28, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies {
exclude module: 'support-annotations'
})

implementation 'com.github.teamnewpipe:NewPipeExtractor:06f2144e4daa10'
implementation 'com.github.timfbfbfbfb:NewPipeExtractor:5a51a7f8fc0a62e1374d1ddd08a250e6c05bd840'
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:2.23.0'

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/schabi/newpipe/RouterActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ private void openDownloadDialog() {
sortedVideoStreams);

FragmentManager fm = getSupportFragmentManager();
DownloadDialog downloadDialog = DownloadDialog.newInstance(result);
DownloadDialog downloadDialog = DownloadDialog.newInstance(result, null);
downloadDialog.setVideoStreams(sortedVideoStreams);
downloadDialog.setAudioStreams(result.getAudioStreams());
downloadDialog.setSelectedVideoStream(selectedVideoStreamIndex);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.schabi.newpipe.database.playlist.model;

import android.text.TextUtils;

import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.Ignore;
Expand Down Expand Up @@ -72,10 +74,16 @@ public PlaylistRemoteEntity(final PlaylistInfo info) {

@Ignore
public boolean isIdenticalTo(final PlaylistInfo info) {
return getServiceId() == info.getServiceId() && getName().equals(info.getName()) &&
getStreamCount() == info.getStreamCount() && getUrl().equals(info.getUrl()) &&
getThumbnailUrl().equals(info.getThumbnailUrl()) &&
getUploader().equals(info.getUploaderName());
/*
* Returns boolean comparing the online playlist and the local copy.
* (False if info changed such as playlist name or track count)
*/
return getServiceId() == info.getServiceId()
&& getStreamCount() == info.getStreamCount()
&& TextUtils.equals(getName(), info.getName())
&& TextUtils.equals(getUrl(), info.getUrl())
&& TextUtils.equals(getThumbnailUrl(), info.getThumbnailUrl())
&& TextUtils.equals(getUploader(), info.getUploaderName());
}

public long getUid() {
Expand Down
73 changes: 63 additions & 10 deletions app/src/main/java/org/schabi/newpipe/download/DownloadDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
Expand All @@ -46,6 +48,7 @@
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.extractor.utils.Localization;
import org.schabi.newpipe.fragments.list.playlist.PlaylistFragment;
import org.schabi.newpipe.report.ErrorActivity;
import org.schabi.newpipe.report.UserAction;
import org.schabi.newpipe.settings.NewPipeSettings;
Expand Down Expand Up @@ -76,7 +79,8 @@
import us.shandian.giga.service.DownloadManagerService.DownloadManagerBinder;
import us.shandian.giga.service.MissionState;

public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheckedChangeListener, AdapterView.OnItemSelectedListener {
public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheckedChangeListener,
AdapterView.OnItemSelectedListener {
private static final String TAG = "DialogFragment";
private static final boolean DEBUG = MainActivity.DEBUG;
private static final int REQUEST_DOWNLOAD_SAVE_AS = 0x1230;
Expand Down Expand Up @@ -107,21 +111,27 @@ public class DownloadDialog extends DialogFragment implements RadioGroup.OnCheck
private RadioGroup radioStreamsGroup;
private TextView threadsCountTextView;
private SeekBar threadsSeekBar;
private CheckBox smartDownloadCheckbox;
private DownloadSetting downloadSetting;

@Nullable
private PlaylistFragment.PlaylistDownloadCallback playlistDownloadCallback;

private SharedPreferences prefs;

public static DownloadDialog newInstance(StreamInfo info) {
public static DownloadDialog newInstance(StreamInfo info, @Nullable PlaylistFragment.PlaylistDownloadCallback callback) {
DownloadDialog dialog = new DownloadDialog();
dialog.setInfo(info);
dialog.setPlaylistCallback(callback);
return dialog;
}

public static DownloadDialog newInstance(Context context, StreamInfo info) {
public static DownloadDialog newInstance(Context context, StreamInfo info, @Nullable PlaylistFragment.PlaylistDownloadCallback callback) {
final ArrayList<VideoStream> streamsList = new ArrayList<>(ListHelper.getSortedStreamVideosList(context,
info.getVideoStreams(), info.getVideoOnlyStreams(), false));
final int selectedStreamIndex = ListHelper.getDefaultResolutionIndex(context, streamsList);

final DownloadDialog instance = newInstance(info);
final DownloadDialog instance = newInstance(info, callback);
instance.setVideoStreams(streamsList);
instance.setSelectedVideoStream(selectedStreamIndex);
instance.setAudioStreams(info.getAudioStreams());
Expand Down Expand Up @@ -162,6 +172,10 @@ public void setSelectedVideoStream(int selectedVideoIndex) {
this.selectedVideoIndex = selectedVideoIndex;
}

public void setPlaylistCallback(PlaylistFragment.PlaylistDownloadCallback callback) {
this.playlistDownloadCallback = callback;
}

public void setSelectedAudioStream(int selectedAudioIndex) {
this.selectedAudioIndex = selectedAudioIndex;
}
Expand Down Expand Up @@ -258,6 +272,10 @@ public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceStat
radioStreamsGroup = view.findViewById(R.id.video_audio_group);
radioStreamsGroup.setOnCheckedChangeListener(this);

smartDownloadCheckbox = view.findViewById(R.id.dialog_download_checkbox_intelligent);
if (playlistDownloadCallback != null)
smartDownloadCheckbox.setVisibility(View.VISIBLE);

initToolbar(view.findViewById(R.id.toolbar));
setupDownloadOptions();

Expand Down Expand Up @@ -364,12 +382,29 @@ private void initToolbar(Toolbar toolbar) {
okButton = toolbar.findViewById(R.id.okay);
okButton.setEnabled(false);// disable until the download service connection is done

if (playlistDownloadCallback != null) {
toolbar.setTitle(getResources().getString(R.string.download) + " (" +
getResources().getString(R.string.playlist) + ")");
MenuItem menuItem = toolbar.getMenu().findItem(R.id.skip);
menuItem.setVisible(true);
} else {
toolbar.setTitle(R.string.download_dialog_title);
}

toolbar.setOnMenuItemClickListener(item -> {

if (item.getItemId() == R.id.okay) {
prepareSelectedDownload();
return true;

} else if (item.getItemId() == R.id.skip) {
if (playlistDownloadCallback != null) {

playlistDownloadCallback.accept(null);
}
}
return false;

getDialog().dismiss();
return true;
});
}

Expand Down Expand Up @@ -780,20 +815,27 @@ private void continueSelectedDownload(@NonNull StoredFileHelper storage) {
String[] psArgs = null;
String secondaryStreamUrl = null;
long nearLength = 0;
String videoResolution = null;
int audioBitrate = -1;
Locale subtitleLocale = null;

// more download logic: select muxer, subtitle converter, etc.
switch (radioStreamsGroup.getCheckedRadioButtonId()) {
case R.id.audio_button:
kind = 'a';
selectedStream = audioStreamsAdapter.getItem(selectedAudioIndex);
AudioStream audioStream = audioStreamsAdapter.getItem(selectedAudioIndex);
audioBitrate = audioStream.getAverageBitrate();
selectedStream = audioStream;

if (selectedStream.getFormat() == MediaFormat.M4A) {
psName = Postprocessing.ALGORITHM_M4A_NO_DASH;
}
break;
case R.id.video_button:
kind = 'v';
selectedStream = videoStreamsAdapter.getItem(selectedVideoIndex);
VideoStream videoStream = videoStreamsAdapter.getItem(selectedVideoIndex);
videoResolution = videoStream.getResolution();
selectedStream = videoStream;

SecondaryStreamHelper<AudioStream> secondaryStream = videoStreamsAdapter
.getAllSecondary()
Expand All @@ -820,7 +862,9 @@ private void continueSelectedDownload(@NonNull StoredFileHelper storage) {
case R.id.subtitle_button:
threads = 1;// use unique thread for subtitles due small file size
kind = 's';
selectedStream = subtitleStreamsAdapter.getItem(selectedSubtitleIndex);
SubtitlesStream subtitlesStream = subtitleStreamsAdapter.getItem(selectedSubtitleIndex);
subtitleLocale = subtitlesStream.getLocale();
selectedStream = subtitlesStream;

if (selectedStream.getFormat() == MediaFormat.TTML) {
psName = Postprocessing.ALGORITHM_TTML_CONVERTER;
Expand All @@ -840,8 +884,17 @@ private void continueSelectedDownload(@NonNull StoredFileHelper storage) {
} else {
urls = new String[]{selectedStream.getUrl(), secondaryStreamUrl};
}
this.downloadSetting = new DownloadSetting(storage, threads, urls, currentInfo.getUrl(), kind, psName, psArgs,
nearLength, videoResolution, audioBitrate, subtitleLocale);
DownloadManagerService.startMission(context, downloadSetting);

DownloadManagerService.startMission(context, urls, storage, kind, threads, currentInfo.getUrl(), psName, psArgs, nearLength);
if (playlistDownloadCallback != null) {
if (smartDownloadCheckbox.isChecked() && downloadSetting != null) {
playlistDownloadCallback.accept(downloadSetting);
} else {
playlistDownloadCallback.accept(null);
}
}

dismiss();
}
Expand Down
80 changes: 80 additions & 0 deletions app/src/main/java/org/schabi/newpipe/download/DownloadSetting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package org.schabi.newpipe.download;

import java.util.Locale;

import us.shandian.giga.io.StoredFileHelper;

public class DownloadSetting {

private StoredFileHelper storedFileHelper;
private int threadCount;
private String[] urls;
private char kind;
private String psName;
private String[] psArgs;
private Long nearLength;
private String source;
private String videoResolution;
private int audioBitRate;
private Locale subtitleLocale;

public DownloadSetting(StoredFileHelper storedFileHelper, int threadCount, String[] urls,
String source, char kind, String psName, String[] psArgs, Long nearLength,
String videoResolution, int audioBitRate, Locale subtitleLocale) {
this.storedFileHelper = storedFileHelper;
this.threadCount = threadCount;
this.urls = urls;
this.kind = kind;
this.psName = psName;
this.psArgs = psArgs;
this.nearLength = nearLength;
this.source = source;
this.videoResolution = videoResolution;
this.audioBitRate = audioBitRate;
this.subtitleLocale = subtitleLocale;
}

public StoredFileHelper getStoredFileHelper() {
return storedFileHelper;
}

public int getThreadCount() {
return threadCount;
}

public String[] getUrls() {
return urls;
}

public char getKind() {
return this.kind;
}

public String getPsName() {
return this.psName;
}

public String[] getPsArgs() {
return this.psArgs;
}

public Long getNearLength() {
return this.nearLength;
}

public String getSource() {
return this.source;
}

public String getVideoResolution() {
return this.videoResolution;
}

public int getAudioBitRate() {
return this.audioBitRate;
}

public Locale getSubtitleLocale() {
return this.subtitleLocale;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ public void handleResult(@NonNull StreamInfo info) {

public void openDownloadDialog() {
try {
DownloadDialog downloadDialog = DownloadDialog.newInstance(currentInfo);
DownloadDialog downloadDialog = DownloadDialog.newInstance(currentInfo, null);
downloadDialog.setVideoStreams(sortedVideoStreams);
downloadDialog.setAudioStreams(currentInfo.getAudioStreams());
downloadDialog.setSelectedVideoStream(selectedVideoStreamIndex);
Expand Down
Loading