Created
May 30, 2025 10:56
-
-
Save Kishibe3/96f6a407e4172948fc8e03ee80de0653 to your computer and use it in GitHub Desktop.
using playboard.co api to obtain most view and comment videos in Taiwan over past 30 days
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']; | |
video_ids.push(...js['list'].map(e => e.itemId)); | |
} | |
catch (e) { | |
break; | |
} | |
} | |
return video_ids; | |
} | |
let result = await Promise.all( | |
Array.from({ length: 30 }, (_, i) => i + 1) | |
.map(e => Date.UTC(new Date().getUTCFullYear(), new Date().getUTCMonth(), new Date().getUTCDate() - e) / 1000) | |
.map(e => get_video_id(e, 20)) | |
); | |
result = Array.from(new Set(result.flat())); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment