Skip to content

Commit

Permalink
fixed wrong song downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
0PandaDEV committed Apr 10, 2024
1 parent 5a824f4 commit e21bf49
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pages/search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const downloadSong = async (url) => {
console.error("Invalid YouTube URL.");
return;
}
const videoId = match[1] + ".webm";
const videoId = match[1] + ".mp3";
await Download.downloadVideoAsMp3(url, videoId);
DiscordRPC.clear()
} catch (error) {
Expand Down
7 changes: 4 additions & 3 deletions src-tauri/src/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ struct ApiItem {

#[tauri::command]
pub async fn download(url: String, name: String) -> Result<()> {
let watch_id = url.trim_start_matches("https://www.youtube.com/watch?v=");
let meta_id = url.trim_start_matches("https://www.youtube.com/watch?v=");
let watch_id = url.trim_start_matches("https://www.youtube.com");

let client = Client::new();
let url = "https://wave.wireway.ch/api/transcode/download/music?q=/watch?v=06JYzej_NJ0";
let url = format!("https://wave.wireway.ch/api/transcode/download/music?q={}", watch_id);
let response = client.get(url).send().await?;

let mut path = PathBuf::new();
Expand All @@ -53,7 +54,7 @@ pub async fn download(url: String, name: String) -> Result<()> {
let content = response.bytes().await?;
file.write_all(&content)?;

let api_url = format!("https://wireway.ch/api/musicAPI/search/?q={}", watch_id);
let api_url = format!("https://wireway.ch/api/musicAPI/search/?q={}", meta_id);
let resp_body = reqwest::get(&api_url).await?.text().await?;
let api_response: ApiResponse = serde_json::from_str(&resp_body)?;

Expand Down

0 comments on commit e21bf49

Please sign in to comment.