wiki/docs/web-services.md

62 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Web Services
## General
### Remove query string from downloaded files
:::shell
for i in *\?*; do echo mv "$i" "$(echo $i | cut -d'?' -f 1)"; done
## Mora
### Get title listing (for MusicBrainz)
:::js
[...document.querySelectorAll('.package_table tr')].map(el => {try {return `${el.querySelector('.package_td1').innerText} ${el.querySelector('.package_td2').innerText} ${el.querySelector('.package_td3').innerText} ${el.querySelector('.package_td4').innerText.split('\n')[0]}`} catch(e) {}}).slice(1).join('\n')
## Instagram
### Download picture in highest quality available
https://instagram.com/p/SHORTCODE/media/?size=l
## Bandcamp
### Get title listing (for MusicBrainz)
:::js
[...document.querySelectorAll('#track_table .track_row_view')].map(el => `${el.querySelector('.track_number').innerText} ${el.querySelector('.track-title').innerText} (${el.querySelector('.time').innerText})`).join("\n")
### Show total purchase value
Works on https://bandcamp.com/USERNAME/purchases
The result needs to be feeded into an intelligent calculator like qalc.
:::js
Array.from(document.querySelectorAll(".col.purchases-item-total div")).map(el => {const raw = el.children[1].innerText.replace("\n", " ").replace(",", ""); return raw.substr(1, raw.len)}).join(" + ")
## Ototoy
### Get title listing (for MusicBrainz)
:::js
Array.from(document.querySelectorAll('#tracklist tr:not(:nth-child(1))')).map(el => el.querySelector('span[id^="title-"]').innerText + " " + el.querySelector('td:nth-child(3)').innerText).join("\n")
## SteamDB
### Get stats as json
:::js
console.log(JSON.stringify(Array.from(document.querySelectorAll('#js-achievements table tbody tr')).map(row => { const cols = row.querySelectorAll('td'); return { name: cols[0].innerText, description: cols[1].querySelector('p.i').innerText, displayName: cols[1].childNodes[0].textContent.replace(/\n/g, ''), hidden: "0", icon: "achievements/" + cols[0].innerText + ".jpg", icongray: "achievements/" + cols[0].innerText + "_gray.jpg" } })))
## YouTube
### Convert takeout playlists to Invidious format
Incredibly ugly, but it works™.
If you want the import to succeed remove the liked video playlist before importing.
:::shell
(echo '{"playlists":['; (for i in *.csv; do echo '{"title": "'"${i%%.csv}"'", "description": "", "privacy": "private", "videos": ["'"$(tail -n +5 "$i" | head -n -1 | cut -d',' -f1| perl -p -e 's/\n/","/' | head -c -3)"'"]},'; done)|head -c -2; echo ']}') > playlists.json