Skip to content

Instantly share code, notes, and snippets.

View Tokariew's full-sized avatar
💭
🦦

Tokariew Tokariew

💭
🦦
View GitHub Profile
@Tokariew
Tokariew / dmenumpd.sh
Created October 24, 2021 10:44
dmenu scripts
#!/bin/sh
chosen=$(printf "%s\nAll" "$(ls ~/Music)" | dmenu -i -p "select folder to shuffle")
if [ -z "$chosen" ]; then
exit 0
else
killall ashuffle
grouping=$(printf "Yes\nNo" | dmenu -i -p "Group by album?")
[ "$grouping" = "Yes" ] && test="ashuffle --by-album" || test="ashuffle --queue-buffer 2"
#!/bin/python3
from concurrent.futures import ThreadPoolExecutor
from pathlib import Path
import requests
from bs4 import BeautifulSoup
from slugify import slugify as restring
from termcolor import colored
# script to download books from wolnelektury.pl site
@Tokariew
Tokariew / flac.py
Last active February 19, 2020 18:47
resize album arts in flac files
import argparse
from concurrent.futures import ProcessPoolExecutor
from io import BytesIO
from pathlib import Path
from imageio import imread, imwrite
from skimage.transform import resize
from mutagen.flac import FLAC, Picture
@Tokariew
Tokariew / to_opus.py
Last active November 24, 2019 17:13
Simple function to encode wav/flac to opus in given folder
def to_opus(folder='.', ext='flac', bitrate=48):
from os import cpu_count
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor
from subprocess import call
file_list = [file.name for file in Path(folder).iterdir() if file.is_file() and ext in file.name]
commands = [f'opusenc --bitrate {bitrate} --framesize 60 --discard-pictures --quiet "{file}" "{file.replace(ext, "opus")}"' for file in file_list]
with ThreadPoolExecutor(max_workers=cpu_count()) as executor:
for command in executor.map(call, commands):
pass
@Tokariew
Tokariew / humblebundle.py
Last active May 12, 2020 13:12
Simple script to download newest purchases from humble bundle website. If some item exist in multiple purchases, will download only one copy. Have ability to download only from newest purchases.
import argparse
import hashlib
import http.cookiejar
import re
import time
from concurrent.futures import ThreadPoolExecutor
from math import floor, log2
from pathlib import Path
import requests
@Tokariew
Tokariew / jamendo.py
Last active February 19, 2020 18:50
Download flac tracks from jamendo.com based on artist or album url
import argparse
import json
import re
import time
from concurrent.futures import ThreadPoolExecutor
from itertools import repeat
from pathlib import Path
import requests
@Tokariew
Tokariew / wunderground.py
Last active February 19, 2020 18:51
Download weather data from wunderground site using new API
import json
import os
from concurrent.futures import ThreadPoolExecutor
from datetime import date, timedelta
from time import sleep
import requests
API_KEY = '' # fill your API key
STATION_ID = '' # pws of intertest