Skip to content

Instantly share code, notes, and snippets.

View jhubble's full-sized avatar

Jeremy Hubble jhubble

View GitHub Profile
@jhubble
jhubble / iTunesYears.sh
Last active April 26, 2024 19:26
Get statistics of music by year from iTunes (Mac Music) library
# First export the iTunes ( aka "Music") Library.xml
# Get a list of all years present
cat Library.xml|grep Year |grep integer |sed 's/[^0-9]*//g' |sort |uniq >allyears.txt
# get a list of years to compare against (change to appropiate start and end years)
seq 1500 2024 >from1500.txt
# now see which years are missing
comm -13 allyears.txt from1500.txt
# To see what are the most common years:
cat Library.xml|grep Year |grep integer |sed 's/[^0-9]*//g' |sort |uniq -c |sort -n
@jhubble
jhubble / outputMusicList.js
Created March 18, 2023 19:13
Get one line for each entry in a mediainfo output
// Output 1 line mediainfo for files
// TYPICAL USAGE:
// mediainfo sourceDir --Output=JSON > source.json
// node outputMusicList.js source.json
const fs = require("fs");
var args = process.argv;
if (args.length < 3) {
console.error("Usage: node outputMusicList.js fileWithSource.json");
@jhubble
jhubble / getGenre.js
Created March 18, 2023 19:11
get genre information from a medianfo json file
const fs = require('fs');
const filename = process.argv[2];
const mediacontents = JSON.parse(fs.readFileSync(filename, "utf8"));
const index = {};
const genres = {};
mediacontents.forEach((file) => {
try {
const filename = file.media["@ref"];
@jhubble
jhubble / updateTags.js
Created March 18, 2023 17:54
Change tags of all mp3s in directory from Title: Title (Artist) to Title: Title Artist: Artist
//
// For all files in directory (mp3s), change Title and Artist tags
// From: Title: This is the name (this is the artist)
// To: Title: This is the name Artist: this is the artist
// Must npm install node-id3 before running
const NodeID3 = require('node-id3');
var fs = require('fs');
const dir = process.argv[2];
if (!dir || dir.indexOf('-') === 0) {
@jhubble
jhubble / getGenres.sh
Created March 3, 2023 17:37
Use JQ to get genres from a mediainfo dump for music files (mp3, etc.)
mediainfo -Output=JSON . > musicFiles.json
cat musicFiles.json |jq '.[].media| "\(."@ref") = \(.track[0].Genre)"' >genres.txt
@jhubble
jhubble / findDupMusic.js
Last active March 18, 2023 19:09
find duplicate songs
// Compare to mediainfo json files generated with mediainfo . --Output=JSON
// run with node findDupMusic.js source.json possibleDups.json
// Will output files in possibleDups that are in source
// add trailing -delete option to delete these duplicate files
// A trailing -fource after delete will delete even if source file not present
// All options are super dumb and dependent on place
const fs = require("fs");
const getOptions = (args) => {
const options = {};
@jhubble
jhubble / atom.xslt
Last active January 31, 2023 08:30
Output a blogger dump from oldest to newest in html format. Run with xsltproc atom.xsl bloggerdump.xml >out.html
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom"
exclude-result-prefixes="atom"
>
<xsl:output method="html" omit-xml-declaration="no"/>
<xsl:template match="/atom:feed">
<h1>Feed</h1>
<xsl:for-each select="atom:entry">
@jhubble
jhubble / delta.py
Created January 21, 2023 23:00
Convert Delta Skymiles history HTML output to CSV
#!/usr/local/bin/python3
# Save the html from Delta Skymiles account activity as "skymiles.html"
# Then run this python script
# It will output tab delimited output with date, description, miles, and details
# Will be sorted from oldest to newest
from bs4 import BeautifulSoup as bs
from bs4 import BeautifulSoup
@jhubble
jhubble / minilister.bas
Last active December 19, 2022 02:57
Print directory listings for commodore 64 sequential or program files. Manually typed in from an old printout, so may have some errors. quick_directory_misc
5 DIMN$(144)
6 SP$=" "
10 PRINT"MINI LISTER"
20 PRINT"LIST PROGRAM SEQUENTIAL, OR ALL":F=0
30 GETA$:IFA$=""THEN30
40 IFA$="P"THENF=1:GOTO65
65 PRINT" PRESS ANY KEY WHEN PRINTER ON LINE, AND"
66 PRINT" DISK IS IN DRIVE READY TO BE CATALOGED":POKE198,0:WAIT198,1
67 OPEN4,4:POKE198,0
70 OPEN1,8,0,"$0
@jhubble
jhubble / spiralSort.js
Created June 15, 2022 22:40
Spiral or Snail sort
// Sort an array in "Spiral" fashion, something like a snail
const spiral = (arr) => {
let out = [];
let k;
while (arr.length) {
// top
while (k = arr[0].shift()) { out.push(k); }
arr.shift();
if (!arr.length) {