Created
May 18, 2023 04:26
-
-
Save alpaca-honke/2320137721a7e0bf98146d78d6ab0e69 to your computer and use it in GitHub Desktop.
先頭行に、world.kiite.jp/api/get/mykw/all2dの返すjsonを設定すると、ブラウザのコンソールにID、曲名、投稿日、再生回数、座標が、X座標の昇順に出力
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 all2d = {"results":{"songs":[{"id":"sm36831697","x":0.04003326635921189,"y":0.22361432492516653},{"id":"sm41189078","x":0.2732249715144877,"y":0.9073456847676495},{"id":"sm41949707","x":0.12493632930198527,"y":0.6485061130126495},{"id":"sm41940982","x":0.12682895541908135,"y":0.5164925109124241},{"id":"sm41948432","x":0.9331895616364733,"y":0.784587830558454},{"id":"sm40983659","x":0.5718792819986569,"y":0.8614226500930409},{"id":"sm41979997","x":0.9065569854238713,"y":0.9387957286717394},{"id":"sm42005680","x":0.28048626073098964,"y":0.488367640895252},{"id":"sm41541853","x":0.23146584390554556,"y":0.8336652904420125},{"id":"sm40350268","x":0.5995654390679105,"y":0.5501930735922899},{"id":"sm41953510","x":0.4288058233528869,"y":0.7862240067093591},{"id":"sm38624165","x":0.04842555651284972,"y":0.6078968412911714},{"id":"sm41844273","x":0.7820967406693694,"y":0.946924220639788},{"id":"sm41924928","x":0.12581060622114593,"y":0.7770283513439185},{"id":"sm41955162","x":0.20022059186021315,"y":0.860881753543763},{"id":"sm41952229","x":0.05893808519883188,"y":0.6070218072760335},{"id":"sm41948106","x":0.1465896922784928,"y":0.40082656694339125},{"id":"sm41946784","x":0.503287919542664,"y":0.38644870527101755},{"id":"sm41948903","x":0.34866661534118537,"y":0.6180185389978289},{"id":"sm41955561","x":0.2798048189083052,"y":0.6411640622747632},{"id":"sm41606052","x":0.04780366471094874,"y":0.7453703214375235},{"id":"sm40350368","x":0.12776865089852563,"y":0.8648009540343687},{"id":"sm41720763","x":0.04674905840671565,"y":0.6708099837593007},{"id":"sm41715327","x":0.42716799846424475,"y":0.7572683325408982},{"id":"sm37950704","x":0.2207659546630821,"y":0.49231549937279623},{"id":"sm41354339","x":0.1284786542588179,"y":0.7958643549626777},{"id":"sm41184224","x":0.01620239887552015,"y":0.7600488356394046},{"id":"sm41087797","x":0.074100739317198,"y":0.7683546815181255},{"id":"sm41193299","x":0.06140819329433868,"y":0.8505040767952319},{"id":"sm41190526","x":0.4069468509435671,"y":0.9735651966556191},{"id":"sm39608927","x":0.024076769913673867,"y":0.7326715881365989},{"id":"sm39257413","x":0.004853247981259849,"y":0.8751087061055474},{"id":"sm38833751","x":0.008886067239898158,"y":0.6229813645316918},{"id":"sm39722490","x":0.0783126166276104,"y":0.4457490597175255},{"id":"sm39217773","x":0.014174122206154797,"y":0.7964217838564533},{"id":"sm36053074","x":0.014310740862229082,"y":0.7613420054383228},{"id":"sm40886720","x":0.25085027533008475,"y":0.6775961171112238},{"id":"sm30156654","x":0.011161926242448297,"y":0.5605728713389403},{"id":"sm40891070","x":0.1306638227576074,"y":0.7578746158798572},{"id":"sm40943551","x":0.3214408990137771,"y":0.8918635673360662},{"id":"sm18198019","x":0.014829167524418232,"y":0.5551269550838757},{"id":"sm17520775","x":0.036138744429458865,"y":0.3305194551442162},{"id":"sm39309935","x":0.3425597983765742,"y":0.8205344132372168},{"id":"sm38814259","x":0.15268616725281997,"y":0.4814682684684357},{"id":"sm40244309","x":0.044035004021945275,"y":0.7629204707267545},{"id":"sm39881925","x":0.1685136920447205,"y":0.5811293359179815},{"id":"sm40625482","x":0.05411603249416168,"y":0.7328578126840631},{"id":"sm39469505","x":0.7380126331985641,"y":0.1565711041328304},{"id":"sm38937833","x":0.9537813019360932,"y":0.3976877888749206},{"id":"sm39837134","x":0.29621046059057954,"y":0.7134285755797036},{"id":"sm39911812","x":0.29897041213359654,"y":0.9150841353055604},{"id":"sm40347559","x":0.353765919581541,"y":0.8965229947974108}],"creators":[],"users":[]},"__response_ms":9}; | |
| const songs = all2d.results.songs; | |
| const base_url = "https://cafeapi.kiite.jp/api/songs/by_video_ids?video_ids="; | |
| let output = []; | |
| const promise = new Promise(() => {songs.forEach(element => { | |
| var xhr = new XMLHttpRequest; | |
| var id = element.id; | |
| var x = element.x; | |
| var y = element.y; | |
| var url = base_url + id; | |
| xhr.open("GET", url, false); | |
| console.log(url); | |
| xhr.send(); | |
| if (xhr.status === 200){ | |
| var response = JSON.parse(xhr.responseText); | |
| console.log(response); | |
| var title = response[0].title; | |
| var date = response[0].published_at; | |
| var view_count = response[0].view_counter; | |
| str_id = String(id); | |
| output.push( | |
| { | |
| "id": str_id, | |
| "title": title, | |
| "date": date, | |
| "view": view_count, | |
| "x": x, | |
| "y": y | |
| } | |
| ); | |
| } | |
| });}).then( | |
| SortAndOutput() | |
| ); | |
| function SortAndOutput() { | |
| output.sort((a,b) => a.x -b.x); | |
| console.table(output); | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
なんかPromiseのとこ、コードブロックおかしくね?
まいいや