i icon indicating copy to clipboard operation
i copied to clipboard

Twitter Spaces Downloader Shortcut

Open extratone opened this issue 3 years ago • 2 comments

Updated 08242022-034359


Social


Download recorded Twitter Spaces and convert them to .mp3 locally and swiftly.

pip install twspace-dl

Requirements

This shortcut uses the most reliable command line tool for downloading Twitter Spaces (at the time of its release, anyway) - a python package called twspace-dl. Even first time users of a-Shell or a-Shell Mini should find its installation process - pip install twspace-dl - absurdly quick.

By default, it receives a single recorded Twitter Spaces share URL (ex: https://twitter.com/i/spaces/1BdGYwZBgEzxX) from either the Share Sheet or the system clipboard, from which it parses the ID of the space before inserting the full URL into a standard twspace-dl download command:

twspace_dl -i ${URL}

Because of a-Shell's unique configuration and the way it interacts with Shortcuts, -o ~/Documents/audio/${id}.m4a is also added to the command to specify a usable location of the initial .m4a file.

(If you're satisfied with that format, feel free to delete the following command.)

Twitter Spaces Downloader Shortcut a-Shell Output

Since ffmpeg comes with both a-Shells, only a single additional step is required to convert incoming Spaces audio files to .mp3 format:

ffmpeg -i ~/Documents/audio/${id}.m4a -c:v copy -c:a libmp3lame -q:a 4 ~/Documents/audio/${id}.mp3

At least at the time of this writing, I think you'll find this exact configuration to be particularly efficient/apt for the average bitrates we're currently seeing from the platform in this context.


Video

Description

Download recorded Twitter Spaces and convert them to .mp3 locally and swiftly.

  • RoutineHub: https://routinehub.co/shortcut/12865
  • iCloud Share URL: https://www.icloud.com/shortcuts/0740f31420ce471698689e949e68ff7d
  • twspace-dl: https://github.com/HoloArchivists/twspace-dl
  • a-Shell: https://apps.apple.com/us/app/a-shell/id1473805438
  • a-Shell Mini: https://apps.apple.com/us/app/a-shell-mini/id1543537943
  • Raw Output Example (as shown:) https://davidblue.wtf/audio/1YpKkZkDgXZxj.mp3
  • GitHub Issue: https://github.com/extratone/i/issues/251

※⃣ ※⃣ ※⃣ ※⃣ ※⃣ ※⃣ ※⃣ ※⃣ ※⃣ ※⃣ World Wide Web: https://bilge.world Contact Card: https://davidblue.wtf/db.vcf Twitter: https://twitter.com/NeoYokel Mastodon: https://mastodon.social/@DavidBlue Instagram: https://instagram.com/asphaltapostle [email protected]

【※】【※】【※】【※】【※】【※】【※】【※】【※】【※】

『※』『※』『※』『※』『※』『※』『※』『※』『※』『※』

≋※≋※≋※≋※≋※≋※≋※≋※≋※≋※≋

░※░※░※░※░※░※░※░※░※░※░


Example Output


Jellycuts

import Shortcuts
import aShell
#Color: grape, #Icon: microphone

/*
Download recorded Twitter Spaces and convert them to .mp3 locally and swiftly.

𝗠𝘆 𝗰𝗼𝗻𝘁𝗮𝗰𝘁 𝗶𝗻𝗳𝗼𝗿𝗺𝗮𝘁𝗶𝗼𝗻:
Email: [email protected]
Contact card: https://davidblue.wtf/db.vcf
RoutineHub Profile: https://routinehub.co/user/blue
GitHub: https://github.com/extratone
iOS-specific Repository: https://github.com/extratone/i
Telegram: https://t.me/DavidBlue
Telegram Channel: https://t.me/extratone
Discord: https://davidblue.wtf/discord
Twitter: https://twitter.com/NeoYokel
Reddit: https://reddit.com/u/asphaltapostle
Mastodon: https://mastodon.social/@DavidBlue
EVERYWHERE: https://davidblue.wtf/socialdrop
*/
var url = ShortcutInput
urlComponent(url: "${url.as(URL)}", component: Path) >> urlComponent
splitText(text: Component of URL, separator: Custom, customSeparator: "spaces/") >> splitText
getItemFromList(list: Split Text, type: Last Item) >> getItemFromList
var id = Item from List
text(text: "twspace_dl -i ${id} -o ~/Documents/audio/${id}.mp3 ") >> text
text(text: "ffmpeg -i ~/Documents/audio/${id}.m4a -c:v copy -c:a libmp3lame -q:a 4 ~/Documents/audio/${id}.mp3") >> text 1
text(text: "cp ~/Documents/audio/${id}.mp3 ~group/${id}.mp3") >> text 2
text(text: "open shortcuts://") >> text 3
executeCommand(command: {text}, {text 1}, {text 2}. {text 3}, openWindow: default, keepGoing: true)
waitToReturn()
getFile(fileName: "${id}.mp3") >> file
share(file: {file}) >> share

extratone avatar Aug 24 '22 05:08 extratone

pip install twspace-dl

extratone avatar Aug 24 '22 05:08 extratone

Twitter Spaces Downloader Shortcut a-Shell Output

extratone avatar Aug 24 '22 08:08 extratone