From b3032dc640449904e4345c65cf254e36f3d074d1 Mon Sep 17 00:00:00 2001 From: huzfm Date: Wed, 2 Oct 2024 10:21:50 +0530 Subject: [PATCH 1/3] Added a prompt to choose the number of images --- README.md | 4 ++-- mkbsd.js | 63 ++++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 55 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 2d34182..8deab9c 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ ``` - /$$ /$$ /$$ /$$ /$$$$$$$ /$$$$$$ /$$$$$$$ + /$$ /$$ /$$ /$$ /$$$$$$$ /$$$$$$ /$$$$$$$ | $$$ /$$$| $$ /$$/| $$__ $$ /$$__ $$| $$__ $$ | $$$$ /$$$$| $$ /$$/ | $$ \ $$| $$ \__/| $$ \ $$ | $$ $$/$$ $$| $$$$$/ | $$$$$$$ | $$$$$$ | $$ | $$ | $$ $$$| $$| $$ $$ | $$__ $$ \____ $$| $$ | $$ | $$\ $ | $$| $$\ $$ | $$ \ $$ /$$ \ $$| $$ | $$ | $$ \/ | $$| $$ \ $$| $$$$$$$/| $$$$$$/| $$$$$$$/ -|__/ |__/|__/ \__/|_______/ \______/ |_______/ +|__/ |__/|__/ \__/|_______/ \______/ |_______/ ``` _Because selling out is bad_ diff --git a/mkbsd.js b/mkbsd.js index d02593a..8d568cd 100644 --- a/mkbsd.js +++ b/mkbsd.js @@ -1,14 +1,12 @@ -// Copyright 2024 Nadim Kobeissi -// Licensed under the WTFPL License const fs = require(`fs`); const path = require(`path`); +const readline = require('readline'); -async function main() { +async function main(imageCount) { const url = 'https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s'; - const delay = (ms) => { - return new Promise(resolve => setTimeout(resolve, ms)); - } + const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms)); + try { const response = await fetch(url); if (!response.ok) { @@ -19,13 +17,24 @@ async function main() { if (!data) { throw new Error('⛔ JSON does not have a "data" property at its root.'); } + + const totalFiles = Object.keys(data).length; // Count total available files + console.info(`📦 Total available files: ${totalFiles}`); + + if (imageCount > totalFiles) { + console.warn(`⚠️ You requested ${imageCount} files, but only ${totalFiles} are available. Downloading all available files instead.`); + imageCount = totalFiles; // Limit to available files + } + const downloadDir = path.join(__dirname, 'downloads'); if (!fs.existsSync(downloadDir)) { fs.mkdirSync(downloadDir); console.info(`📁 Created directory: ${downloadDir}`); } + let fileIndex = 1; for (const key in data) { + if (fileIndex > imageCount) break; // Stop if we've reached the desired count const subproperty = data[key]; if (subproperty && subproperty.dhd) { const imageUrl = subproperty.dhd; @@ -69,7 +78,41 @@ function asciiArt() { console.info(`🤑 Starting downloads from your favorite sellout grifter's wallpaper app...`); } -(() => { - asciiArt(); - setTimeout(main, 5000); -})(); +const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +// Function to start the download process +async function startDownload() { + const url = 'https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s'; + const response = await fetch(url); + const jsonData = await response.json(); + const data = jsonData.data; + + const totalFiles = Object.keys(data).length; // Count total available files + console.info(`📦 Total available files: ${totalFiles}`); + + rl.question('How many images would you like to download? ', (answer) => { + let imageCount = parseInt(answer, 10); + if (isNaN(imageCount) || imageCount <= 0) { + console.error('Please enter a valid positive number.'); + rl.close(); + return; + } + + if (imageCount > totalFiles) { + console.warn(`⚠️ You requested ${imageCount} files, but only ${totalFiles} are available. Downloading all available files instead.`); + imageCount = totalFiles; // Limit to available files + } + + asciiArt(); + setTimeout(() => { + main(imageCount).finally(() => rl.close()); + }, 5000); + }); +} + +// Start the download process +startDownload(); + From 411e76618051d8b0e6c7d41320cfaf9c811532e2 Mon Sep 17 00:00:00 2001 From: huzfm Date: Wed, 2 Oct 2024 10:23:17 +0530 Subject: [PATCH 2/3] Added a prompt to choose the number of images --- mkbsd.js | 1 + 1 file changed, 1 insertion(+) diff --git a/mkbsd.js b/mkbsd.js index 8d568cd..fe4f5ff 100644 --- a/mkbsd.js +++ b/mkbsd.js @@ -1,4 +1,5 @@ + const fs = require(`fs`); const path = require(`path`); const readline = require('readline'); From 9d0ba1c580f0c816a562467432417bf45ff4daea Mon Sep 17 00:00:00 2001 From: Huzaif Mushtaq <125808234+huzfm@users.noreply.github.com> Date: Wed, 2 Oct 2024 10:34:33 +0530 Subject: [PATCH 3/3] Delete README.md --- README.md | 67 ------------------------------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 8deab9c..0000000 --- a/README.md +++ /dev/null @@ -1,67 +0,0 @@ -``` - /$$ /$$ /$$ /$$ /$$$$$$$ /$$$$$$ /$$$$$$$ -| $$$ /$$$| $$ /$$/| $$__ $$ /$$__ $$| $$__ $$ -| $$$$ /$$$$| $$ /$$/ | $$ \ $$| $$ \__/| $$ \ $$ -| $$ $$/$$ $$| $$$$$/ | $$$$$$$ | $$$$$$ | $$ | $$ -| $$ $$$| $$| $$ $$ | $$__ $$ \____ $$| $$ | $$ -| $$\ $ | $$| $$\ $$ | $$ \ $$ /$$ \ $$| $$ | $$ -| $$ \/ | $$| $$ \ $$| $$$$$$$/| $$$$$$/| $$$$$$$/ -|__/ |__/|__/ \__/|_______/ \______/ |_______/ -``` - -_Because selling out is bad_ - -## How to use - -MKBSD comes in two variants! Node.js and Python. - -### Running in Node.js - -1. Ensure you have Node.js installed. -2. Run `node mkbsd.js` -3. Wait a little. -4. All wallpapers are now in a newly created `downloads` subfolder. - -### Running in Python - -1. Ensure you have Python installed. -2. Ensure you have the `aiohttp` Python package installed (`pip install aiohttp`). -3. Run `python mkbsd.py` -4. Wait a little. -5. All wallpapers are now in a newly created `downloads` subfolder. - -## FAQ - -### Q: What's the story behind this? - -On September 24th, 2024, well-known tech YouTuber MKBHD released Panels, a wallpaper app that: - -- Had insanely invasive, unjustified tracking including for location history and search history. -- Charged artists a predatory 50% commission (even Apple takes only 30% for app purchases). -- Forced you to watch two ads for every wallpaper that you wanted to download, and then only letting you download it in SD. -- Gatekept all HD wallpapers behind a **fifty dollars a year subscription**. -- Had many wallpapers that were essentially AI-generated slop or badly edited stock photos. - -Especially given MKBHD's previous criticism of substandard companies and products, people justifiably got upset given that this looked like a pretty blatant grift and cash-grab that is exploitative of the fan base that's trusted his editorial integrity over the past fifteen years. However, on the same day, MKBHD wrote a post doubling down on the app. - -### Q: Aren't you stealing from artists by running this script? - -MKBSD accesses publicly available media through the Panels app's own API. It doesn't do anything shady or illegal. The real problem here is Panels and MKBHD's complete inability to provide a secure platform for the artists that they're ~~exploiting~~ working with. Any other app could have avoided the issues that make MKBSD possible had it been engineered competently. - -## License - -``` - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 - - Copyright (C) 2004 Sam Hocevar - - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. - - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. You just DO WHAT THE FUCK YOU WANT TO. -```