Skip to content

Instantly share code, notes, and snippets.

Janusz Kowalczyk kowalcj0

Block or report user

Report or block kowalcj0

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@kowalcj0
kowalcj0 / dlistmp3.sh
Created Nov 27, 2019
Download all songs from a YT playlist in parallel and convert to 192kbps mp3
View dlistmp3.sh
function dlistmp3() {
youtube-dl -j --flat-playlist "${1}" |\
jq -r '.id' |\
sed 's_^_https://www.youtube.com/watch?v=_' |\
parallel -j4 'youtube-dl -f bestaudio --extract-audio --audio-format mp3 --audio-quality 192K --embed-thumbnail --add-metadata --no-post-overwrites --ignore-errors {}'
}
View move_by_dir_type.py
#!/usr/bin/env python3
import os
import shutil
def what_is_inside(types) -> str:
result = ""
if "mp3" in types and "flac" in types:
result = "both"
if "mp3" in types and not "flac" in types:
@kowalcj0
kowalcj0 / extract_music_urls.py
Created Oct 26, 2018
Extract links to music websites from Mastodon's outbox.json and download them with youtube-dl in parallel with covers and metadata
View extract_music_urls.py
#! /usr/bin/python
"""Extract links to music websites from Mastodon's outbox.json
outbox.json contains all of your toots
"""
import json
from bs4 import BeautifulSoup as Soup
def extract_music_urls():
with open("outbox.json") as f:
@kowalcj0
kowalcj0 / stabilize.sh
Created Sep 8, 2018
Stabilise shaky video with ffmpeg and vid.stab
View stabilize.sh
alias stabilize=stabilize
function stabilize() {
type ffmpeg >/dev/null 2>&1 || { echo >&2 "ffmpeg is required but it's not installed."; return 1; }
video="${1}"
filename="${1%.*}"
extension="${1##*.}"
output="${filename}-stabilized.${extension}"
# calculate transformation vectors
ffmpeg -nostdin -hide_banner -i "${video}" -vf vidstabdetect=stepsize=6:shakiness=8:accuracy=15:result=transform_vectors.trf -f null -
@kowalcj0
kowalcj0 / trim.sh
Created Sep 8, 2018
Trim videos losslessly with ffmpeg
View trim.sh
alias trim=trim
function trim() {
if [ "$#" != "3" ]; then
echo "Please provide all 3 arguments: 'filename start duration'"
return 1
fi
video="${1}"
filename="${1%.*}"
extension="${1##*.}"
@kowalcj0
kowalcj0 / subs.sh
Created Sep 1, 2018
Extract all subtitles from a movie using ffprobe & ffmpeg
View subs.sh
alias subs=subs
function subs() {
movie="${1}"
filename="${1%.*}"
mappings=`ffprobe -loglevel error -select_streams s -show_entries stream=index:stream_tags=language -of csv=p=0 "${movie}"`
OLDIFS=$IFS
IFS=,
( while read idx lang
do
View cheat.sh
function cheat() {
# ${1} - is the language/dmbs/etc
# ${*:2} - your query
# sed 's/ /+/g' - will replace spaces with `+`
curl https://cheat.sh/${1}/`echo "${*:2}" | sed 's/ /+/g'`
}
# example usage:
# cheat python recursion
# cheat python open files
@kowalcj0
kowalcj0 / parallel_pa11y.sh
Last active Jun 12, 2018
run pa11y accessibility scan in parallel and save report for each URL in html file
View parallel_pa11y.sh
sudo dnf install parallel
npm install pa11y pa11y-reporter-html
# the Perl expression {= s:[/\:\?\&\=]:-:g; =} will replace all special charachers '/:?&' in report filename with '-'
parallel 'pa11y --reporter=html {} > {= s:[/\:\?\&\=]:-:g; =}.html' < urls.txt
@kowalcj0
kowalcj0 / urls-checker.py
Created Mar 27, 2018
Modified version of fetch function with semaphore created by: Paweł Miech https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html
View urls-checker.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Modified version of fetch function with semaphore created by: Paweł Miech
src: https://pawelmhm.github.io/asyncio/python/aiohttp/2016/04/22/asyncio-aiohttp.html
"""
import argparse
import asyncio
import sys
from argparse import Namespace
from asyncio import Semaphore
@kowalcj0
kowalcj0 / get_docker_repo_tags.sh
Created Feb 28, 2018
list all the available image tags for a docker hub repo
View get_docker_repo_tags.sh
wget -q https://registry.hub.docker.com/v1/repositories/circleci/python/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'
You can’t perform that action at this time.