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
// obtain through 'playboard video ID.js' | |
let videos = ["7co5DzJZOgg", "Y320amlrojY", "Z6qHyttln60", "u9yUZKL0Ahk", "h7hJhmSdb3c", "bRoXIOSbeFQ", "IWY4YuC7sok", "vhvr2Bp0uSI", "THoFtZh8AXA", "wNUvTugjJ_8", "c3V6B4duDBI", "Lb4WyFL1TO8", "ldxRt2gYKw8", "RXf7En7p5JQ", "xLPk4r07vno", "FU6J6QWzNh8", "pGZv2cJXTKA", "EkPBqSouvRk", "3ymrSO7LQWA", "ZapaUxZITjw", "08_nI9DGgGM", "4Dn7_G7vDVY", "WluyF9b2xY8", "1lg32618VTc", "bzK7gjYNLdc", "hVumexkCSZI", "7V5Xd6bqD2I", "sO-MATukpd4", "sRX6qbKvhtw", "IOpdXl-DtCQ", "-OHNRYpbDEA", "ilJU5e8g5HI", "R-OXZonkRdI", "OFwZB1mmsRo", "6t_5WegPb1k", "gDgK_AH-P04", "OnAlNuVOUCw", "1DcpdFoJx9E", "-a1yIlofajo", "GYfHTZlBTag", "wQphWdiiV3s", "RFi_sxTsH1Q", "yTjvVRhf9hk", "3Cltn9ZtWs0", "G7D3vFSY28U", "-ikNAvHFndg", "Bd1aRKrPj2c", "EpM943dO1lw", "xfGKGjVrRXc", "Ji8Wa-WIfGA", "ycsVjuAkNBQ", "caP3ie9McVI", "z4MdLEcz18g", "4luwCpTcnzM", "LW1D-36Mjug", "YSdNVAhSNEg", "_SXoYHSJYB4", "RVHRDt0pLOw", "h8hnQBNURTQ", "wfZmxUXDcjk", "S9po9TJAab4", "87cp4lQB4nU", "L3wz-Bw8w_g", "mKDrZDy1oB0", "qg3O7Kc |
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
let limiter = new AsyncLimiter(1, 2.4); | |
async function get_video_id(day, cat = 20) { | |
if (cat !== 20 && cat !== 23) // 20 for most view videos, 23 for most comment videos | |
cat = 20; | |
let video_ids = [], cursor = ''; | |
for (let rqcnt = 0; rqcnt < 4; rqcnt++) { | |
try { | |
let js = await limiter.run(() => fetch(`https://lapi.playboard.co/v1/chart/video?${cat}_${new Date(day * 1000).toLocaleDateString('zh-TW', { year:'numeric', month: '2-digit', day: '2-digit' })}_${rqcnt}&locale=en&countryCode=TW&period=${day}&size=25&chartTypeId=20&periodTypeId=2&indexDimensionId=${cat}&indexTypeId=4&indexTarget=25&indexCountryCode=TW&cursor=${cursor}`) | |
.then(e => e.json())); | |
cursor = js['cursor']; |
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
class AsyncLimiter { | |
// Reference https://github.com/mjpieters/aiolimiter/blob/master/src/aiolimiter/leakybucket.py | |
#level = 0; | |
#last_check = 0; | |
#rate_per_sec; | |
#waiters = []; | |
#waker_handle; | |
#id = 0; | |
#Future; |