-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for downloading Spotify songs (#293)
* feat: Added support for downloading Spotify songs * fix: Changed executable name for Spotify in linux and merged copy executables classes * fix: fixed missing variable in Environment class * Added progress bar * added changes to update progress bar * fix: Fixed merge conflicts and broken support for Spotify filename detection in Drifty CLI * chore: Added spotdl executables to resource config --------- Co-authored-by: Saptarshi Sarkar <saptarshi.programmer@gmail.com>
- Loading branch information
1 parent
9a6cdb3
commit 398720d
Showing
24 changed files
with
299 additions
and
170 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"resources": { | ||
"includes": [ | ||
{"pattern": "yt-dlp"} | ||
{"pattern": "yt-dlp"}, | ||
{"pattern": "spotdl_linux"} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"resources": { | ||
"includes": [ | ||
{"pattern": "yt-dlp_macos"} | ||
{"pattern": "yt-dlp_macos"}, | ||
{"pattern": "spotdl_macos"} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
{ | ||
"resources": { | ||
"includes": [ | ||
{"pattern": "yt-dlp.exe"} | ||
{"pattern": "yt-dlp.exe"}, | ||
{"pattern": "spotdl_win.exe"} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package Backend; | ||
|
||
import Enums.Program; | ||
import Utils.Environment; | ||
import Utils.MessageBroker; | ||
import org.apache.commons.io.FileUtils; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.nio.file.FileAlreadyExistsException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
public class CopyExecutables { | ||
private static final MessageBroker M = Environment.getMessageBroker(); | ||
|
||
public void copyExecutables(String[] executableNames) throws IOException { | ||
for (String executableName : executableNames) { | ||
InputStream inputStream = ClassLoader.getSystemResourceAsStream(executableName); | ||
Path executablePath = Program.getExecutablesPath(executableName); | ||
if (!Files.exists(executablePath)) { | ||
if (!executablePath.toFile().getParentFile().exists()) { | ||
FileUtils.createParentDirectories(executablePath.toFile()); | ||
} | ||
try (OutputStream outputStream = Files.newOutputStream(executablePath)) { | ||
if (inputStream != null) { | ||
byte[] buffer = new byte[4096]; | ||
int bytesRead; | ||
while ((bytesRead = inputStream.read(buffer)) != -1) { | ||
outputStream.write(buffer, 0, bytesRead); | ||
} | ||
} | ||
if (!Files.isExecutable(executablePath)) { | ||
ProcessBuilder makeExecutable = new ProcessBuilder("chmod", "+x", executablePath.toString()); | ||
makeExecutable.inheritIO(); | ||
Process chmod = makeExecutable.start(); | ||
chmod.waitFor(); | ||
} | ||
} catch (FileAlreadyExistsException e) { | ||
M.msgLogWarning(executableName + " not copied to " + Program.get(Program.DRIFTY_PATH) + " because it already exists!"); | ||
} catch (InterruptedException e) { | ||
M.msgLogWarning("Failed to make " + executableName + " executable: " + e.getMessage()); | ||
} catch (IOException e) { | ||
M.msgInitError("Failed to copy " + executableName + " executable: " + e.getMessage()); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
398720d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
drifty – ./
drifty-saptarshisarkar12.vercel.app
drifty.vercel.app
drifty-git-master-saptarshisarkar12.vercel.app