You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically title.
In this version i first get the list of content from 'https://storage.googleapis.com/panels-api/data/20240916/content-1a';
And then use HD download key to get the item from data link.
This allows to create folders with pictures names and download all avaliable formats for each picture from data url.
It will download like
downloads
-> Picture Label
-> Picture-hd.jpg
-> Picture-sd.jpg
Note: also used axios but you can replace it with fetch easily (i just had it installed already)
Code:
importaxiosfrom'axios';import{join,normalize}from'path';import{fileURLToPath}from'node:url';import{dirname}from'node:path';importfsfrom'fs';const__filename=fileURLToPath(import.meta.url);const__dirname=dirname(__filename);// URLsconstCONTENT_URL='https://storage.googleapis.com/panels-api/data/20240916/content-1a';constMEDIA_URL='https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~uhd';// Create "downloads" folder if it doesn't existconstdownloadDir=join(__dirname,'downloads');if(!fs.existsSync(downloadDir)){fs.mkdirSync(downloadDir);}constdownloadImage=async(url,filePath)=>{try{constresponse=awaitaxios({
url,method: 'GET',responseType: 'stream',});constwriter=fs.createWriteStream(filePath);response.data.pipe(writer);returnnewPromise((resolve,reject)=>{writer.on('finish',resolve);writer.on('error',reject);});}catch(error){console.error(`Failed to download image from ${url}`,error);}};constdownloadWallpapers=async()=>{try{constcontentResponse=awaitaxios.get(CONTENT_URL);constmediaResponse=awaitaxios.get(MEDIA_URL);constwallpapers=contentResponse.data.wallpapers;for(constwallpaperofwallpapers){constlabel=wallpaper.label.replace(/[/\\?%*:|"<>]/g,'-');// Sanitize folder nameconstfolderPath=join(downloadDir,label);constdlKey=wallpaper?.dlm?.hd;if(!fs.existsSync(folderPath)){fs.mkdirSync(folderPath);}constmediaData=mediaResponse.data.data?.[dlKey]||{};for(constkeyinmediaData){constdownloadLink=mediaData[key];constimageFileName=`${label}-${key}.jpg`;constfilePath=join(folderPath,imageFileName);awaitdownloadImage(downloadLink,filePath);console.log(`Downloaded ${imageFileName} to ${filePath}`);}}}catch(error){console.error('Error downloading wallpapers:',error);}};downloadWallpapers();
The text was updated successfully, but these errors were encountered:
@faithfulojebiyi Need a little more info there friend.
This code worked for me with no issues.
Also, this is not a pull request but rather a suggestion. I trust you can modify the code however you like to suit your needs
@faithfulojebiyi hey, thanks! That is a left over when i tested it because i thought that the folder names do not match the content but turns out that it's just half of them is abstract lol
Removed the return
Basically title.
In this version i first get the list of content from 'https://storage.googleapis.com/panels-api/data/20240916/content-1a';
And then use HD download key to get the item from data link.
This allows to create folders with pictures names and download all avaliable formats for each picture from data url.
It will download like
Note: also used axios but you can replace it with fetch easily (i just had it installed already)
Code:
The text was updated successfully, but these errors were encountered: