Skip to content

Instantly share code, notes, and snippets.

@0scvr
0scvr / spotidl.py
Created September 13, 2023 22:39
Download songs (+metadata) from Spotify with doubledouble.top
import requests
import json
import time
# Function to make a GET request to the given URL with retries
def make_get_request_with_retry(url, params=None, max_retries=5, retry_delay=6):
for _ in range(max_retries):
try:
response = requests.get(url, params=params)
response.raise_for_status()
@0scvr
0scvr / get_song_urls.py
Created September 13, 2023 14:36
Python script to save song URLs from a Spotify playlist in a text file
import spotipy
from spotipy.oauth2 import SpotifyClientCredentials
sp = spotipy.Spotify(auth_manager=SpotifyClientCredentials(client_id="XXXX", client_secret="XXXX"))
pl = sp.playlist('XXXX')
song_urls = []
for x in pl['tracks']['items']:
song_url = x['track']['external_urls']['spotify']
song_urls.append(song_url)
@0scvr
0scvr / yt_music_dl.sh
Created September 9, 2023 18:27
Shell script to download a list of songs from Youtube Music. Requires "gytmdl" to function.
#!/bin/zsh
FAILCTR=0
# Check if a file argument is provided
if [ $# -ne 1 ]; then
echo "Usage: $0 <url_list_file>"
exit 1
fi
url_list_file="$1"
@0scvr
0scvr / dontsleep.ps1
Created April 13, 2023 16:53
Powershell script to prevent Windows from sleeping
param([int]$minutes=60) # input param, 60 minutes if no value provided
$wsh = New-Object -ComObject WScript.Shell
$a = Get-Date # Current time
$b = $a.AddMinutes($minutes) # Target time
while ($a -lt $b) {
# Send Shift+F15
$wsh.SendKeys('+{F15}')
Start-Sleep -seconds 240 # sleep for 4 minutes
@0scvr
0scvr / m3u8_dl.sh
Created October 30, 2022 21:28
Downloading video blobs & HTTP video streams with ffmpeg
ffmpeg -i "http://.../index.m3u8" -c copy my_file.mkv
@0scvr
0scvr / extract-here.sh
Created October 12, 2022 20:45
macOS Automator workflow to extract archives in current directory.
for f in "$@"
do
fdir="$(dirname "${f}")"
/usr/local/bin/7zz e "$f" -o"$fdir"
done
@0scvr
0scvr / pyvenv.sh
Created October 20, 2021 15:46
Python venv commands
# create a virtual environment named env by convention
python3 -m venv env
# make sure to add env/ (or whatever you named your virtual environment) to your .gitignore file
# use the virtual environment
source env/bin/activate
# save dependencies to requirements.txt file
pip freeze > requirements.txt