Skip to content

Instantly share code, notes, and snippets.

View tyler-weiss's full-sized avatar
🧐
Ignorance never gets beyond wonder.

tyler-weiss tyler-weiss

🧐
Ignorance never gets beyond wonder.
View GitHub Profile
@tyler-weiss
tyler-weiss / writeFile.py
Last active February 27, 2024 16:53
quick/ugly Voter-Guide site-configs script: copy row&column from spreadsheet, paste into Numbers, export as its own CSV file, change readFile name to yours, run python3 writeFile.py
import csv
readFile = open('./inputVoterGuide.csv')
outputFile = open('./outVoterGuide.json', 'w')
us_state_to_abbrev = {
"Alabama": "AL",
"Alaska": "AK",
"Arizona": "AZ",
"Arkansas": "AR",
"California": "CA",
const videoUrls = ytplayer.config.args.adaptive_fmts
.split(',')
.map(item => item
.split('&')
.reduce((prev, curr) => (curr = curr.split('='),
Object.assign(prev, {[curr[0]]: decodeURIComponent(curr[1])})
), {})
)
.reduce((prev, curr) => Object.assign(prev, {
[curr.quality_label || curr.type]: curr
function updateUrlParameter(uri, key, value) {
var re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
var separator = uri.indexOf('?') !== -1 ? "&" : "?";
if (!value) {
// remove key-value pair if value is empty
uri = uri.replace(new RegExp("([?&]?)" + key + "=[^&]*", "i"), '');
if (uri.slice(-1) === '?') {
uri = uri.slice(0, -1);
async function getChannelId(key) {
var channel = { id:NaN };
await axios.get(`${Config.BASE_URL}v1/streaming/videos/summary/channels`).then(function(response){
const channelData = response.data as Array<NamedResource>;
channelData.filter(function(item:NamedResource){
return key == slug(item.name);
}).forEach(function(item:NamedResource){
channel = item;
});
}).catch(function(e){