Compare commits

...

2 Commits

  1. 18
      src/main/java/moe/nekojimi/chords/Chords.java
  2. 1
      src/main/java/moe/nekojimi/chords/Downloader.java

@ -437,6 +437,9 @@ public final class Chords extends ListenerAdapter
private static final String PROGRESS_SYMBOLS = " ▏▎▍▌▋▊▉█"; private static final String PROGRESS_SYMBOLS = " ▏▎▍▌▋▊▉█";
private double lastProgressUpdate = 0.0;
private boolean initialUpdateSent = false;
/* /*
🌑🌘🌗🌖🌕 🌑🌘🌗🌖🌕
@ -455,6 +458,7 @@ public final class Chords extends ListenerAdapter
@Override @Override
public void accept(TrackRequest request, Exception ex) public void accept(TrackRequest request, Exception ex)
{ {
boolean shouldUpdate = false;
String response = ""; String response = "";
if (request.getTracks().size() > 1) if (request.getTracks().size() > 1)
response += "Downloading " + request.getTracks().size() + " tracks:\n"; response += "Downloading " + request.getTracks().size() + " tracks:\n";
@ -467,6 +471,7 @@ public final class Chords extends ListenerAdapter
{ {
response += ("Finished downloading " + track + "!"); response += ("Finished downloading " + track + "!");
log("DOWN", "Downloaded " + track); log("DOWN", "Downloaded " + track);
shouldUpdate = true;
} else } else
{ {
Format format = track.getBestFormat(); Format format = track.getBestFormat();
@ -482,7 +487,14 @@ public final class Chords extends ListenerAdapter
String progressDetails = ""; String progressDetails = "";
if (track.getProgress() >= 0) if (track.getProgress() >= 0)
{
if (track.getProgress() >= lastProgressUpdate + 10.0)
{
shouldUpdate = true;
lastProgressUpdate = track.getProgress();
}
progressDetails = " [" + String.format("%.1f", track.getProgress()) + "%]"; progressDetails = " [" + String.format("%.1f", track.getProgress()) + "%]";
}
response += ("Now downloading " + track + formatDetails + progressDetails + " ..."); response += ("Now downloading " + track + formatDetails + progressDetails + " ...");
log("DOWN", "Downloading " + track + "..."); log("DOWN", "Downloading " + track + "...");
@ -491,11 +503,15 @@ public final class Chords extends ListenerAdapter
{ {
response += ("Failed to download " + track + "! Reason: " + ex.getMessage()); response += ("Failed to download " + track + "! Reason: " + ex.getMessage());
log("DOWN", "Failed to download " + track + "! Reason: " + ex.getMessage()); log("DOWN", "Failed to download " + track + "! Reason: " + ex.getMessage());
shouldUpdate = true;
} }
response += "\n"; response += "\n";
} }
if (!response.isEmpty()) if (!response.isEmpty() && (shouldUpdate || initialUpdateSent))
{
request.getInvocation().respond(response); request.getInvocation().respond(response);
initialUpdateSent = true;
}
} }
} }

@ -357,6 +357,7 @@ public class Downloader extends QueueThing<TrackRequest, Track>
+ " --audio-format=wav" + " --audio-format=wav"
+ " --no-playlist" + " --no-playlist"
// + " --extractor-args youtube:player_client=android" // + " --extractor-args youtube:player_client=android"
+ " -N 8"
+ " -o " + getDownloadDir().getAbsolutePath() + "/%(title)s.%(ext)s " + " -o " + getDownloadDir().getAbsolutePath() + "/%(title)s.%(ext)s "
+ request.getUrl().toString(); + request.getUrl().toString();

Loading…
Cancel
Save