Skip to content

Commit

Permalink
no fileName from json
Browse files Browse the repository at this point in the history
  • Loading branch information
RIVEK-Development committed Oct 24, 2023
1 parent 8921873 commit 4325d6e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,12 @@ function parseJson(res, vidForm, sendResponse, download){
HQvideo = HQvideoTwo;
}
}


var name = res["search-results"]["result"]["mediapackage"]["title"];
if(res["search-results"]["result"]["mediapackage"]["title"] != null){
var name = res["search-results"]["result"]["mediapackage"]["title"];
}else{
var name = generateFileName();
console.log("did not get fileName");
}
var url = res["search-results"]["result"]["mediapackage"]["media"]["track"][HQvideo]["url"];


Expand All @@ -67,7 +70,7 @@ function parseJson(res, vidForm, sendResponse, download){

var fileName = name.replaceAll(" - ","-").replaceAll("/","-").replaceAll(/[?%*:;,|"]/g, "").replaceAll(/[\\.<> ]/g, "_").replaceAll("__","_")+ ".mp4";
if(download){
console.log("started download");
console.log("started download "+fileName);
chrome.downloads.download({
url: url,
filename: fileName
Expand Down

0 comments on commit 4325d6e

Please sign in to comment.