This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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){ |