diff --git a/.github/workflows/fetch-artist-charts.yaml b/.github/workflows/fetch-artist-charts.yaml index aaf20fd1..3164bd1f 100644 --- a/.github/workflows/fetch-artist-charts.yaml +++ b/.github/workflows/fetch-artist-charts.yaml @@ -9,17 +9,15 @@ jobs: permissions: contents: write steps: - - name: Checkout + - name: Checkout out this repo uses: actions/checkout@v4 with: ref: ${{ github.head_ref }} - - name: Fetch - uses: JamesIves/fetch-api-data-action@v2 - with: - endpoint: https://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=coryd_&api_key=${{ secrets.LASTFM_API_KEY }}&format=json - configuration: '{ "method": "GET" }' - save-location: 'src/_data/json' - save-name: 'weekly-artist-charts' + - name: Fetch current artist charts + run: |- + data=$(curl 'https://ws.audioscrobbler.com/2.0/?method=user.getweeklyartistchart&user=coryd_&api_key=${{ secrets.LASTFM_API_KEY }}&format=json') \ + charts=$(src/_data/json/weekly-artist-charts.json | jq --argjson jq_data "${data}" '.charts += [$jq_data]') \ + echo $charts > src/_data/json/weekly-artist-charts.json - name: Commit uses: stefanzweifel/git-auto-commit-action@v5 with: diff --git a/src/_data/json/weekly-artist-charts.json b/src/_data/json/weekly-artist-charts.json index 2ef804f3..18e27bd9 100644 --- a/src/_data/json/weekly-artist-charts.json +++ b/src/_data/json/weekly-artist-charts.json @@ -1 +1,3 @@ -{"weeklyartistchart":{"artist":[{"mbid":"0743b15a-3c32-48c8-ad58-cb325350befa","url":"https:\/\/www.last.fm\/music\/blink-182","name":"blink-182","@attr":{"rank":"1"},"playcount":"19"},{"mbid":"aba64937-3334-4c65-90a1-4e6b9d4d7ada","url":"https:\/\/www.last.fm\/music\/Aesop+Rock","name":"Aesop Rock","@attr":{"rank":"2"},"playcount":"18"},{"mbid":"12a9e259-f7cb-4fca-87b1-a6c5fd38c300","url":"https:\/\/www.last.fm\/music\/Hot+Mulligan","name":"Hot Mulligan","@attr":{"rank":"3"},"playcount":"12"},{"mbid":"5c9dd772-a38f-4873-baa8-4b5d9dff3990","url":"https:\/\/www.last.fm\/music\/Spanish+Love+Songs","name":"Spanish Love Songs","@attr":{"rank":"4"},"playcount":"12"},{"mbid":"664c3e0e-42d8-48c1-b209-1efca19c0325","url":"https:\/\/www.last.fm\/music\/The+National","name":"The National","@attr":{"rank":"5"},"playcount":"12"},{"mbid":"a521f1a8-a949-4dcf-ab33-94596cb02787","url":"https:\/\/www.last.fm\/music\/Militarie+Gun","name":"Militarie Gun","@attr":{"rank":"6"},"playcount":"11"},{"mbid":"3ac482b8-1494-4071-a0e9-f192f9d2c2b0","url":"https:\/\/www.last.fm\/music\/Built+to+Spill","name":"Built to Spill","@attr":{"rank":"7"},"playcount":"10"},{"mbid":"6e7aea5b-de9f-4118-ae32-ddea8198864a","url":"https:\/\/www.last.fm\/music\/Dogleg","name":"Dogleg","@attr":{"rank":"8"},"playcount":"10"},{"mbid":"20244d07-534f-4eff-b4d4-930878889970","url":"https:\/\/www.last.fm\/music\/Taylor+Swift","name":"Taylor Swift","@attr":{"rank":"9"},"playcount":"9"},{"mbid":"c16dcdae-a651-42c1-aff8-edda0f463157","url":"https:\/\/www.last.fm\/music\/Soft+Kill","name":"Soft Kill","@attr":{"rank":"10"},"playcount":"8"},{"mbid":"552cd2a3-ac51-464d-8222-dcdbb08a8d2d","url":"https:\/\/www.last.fm\/music\/Tomb+Mold","name":"Tomb Mold","@attr":{"rank":"11"},"playcount":"8"},{"mbid":"","url":"https:\/\/www.last.fm\/music\/Inanna","name":"Inanna","@attr":{"rank":"12"},"playcount":"7"},{"mbid":"","url":"https:\/\/www.last.fm\/music\/AFI","name":"AFI","@attr":{"rank":"13"},"playcount":"6"},{"mbid":"","url":"https:\/\/www.last.fm\/music\/home+is+where","name":"home is where","@attr":{"rank":"14"},"playcount":"6"},{"mbid":"03f9e6f0-7c7f-4fd6-a47f-f0b0425f314b","url":"https:\/\/www.last.fm\/music\/Mis%C3%BEyrming","name":"Misþyrming","@attr":{"rank":"15"},"playcount":"6"},{"mbid":"4ef06a0d-b8d1-42b4-aff8-06f223306cdb","url":"https:\/\/www.last.fm\/music\/Cloud+Rat","name":"Cloud Rat","@attr":{"rank":"16"},"playcount":"5"},{"mbid":"67d1433c-6354-4fb4-bb57-bd21c4904eed","url":"https:\/\/www.last.fm\/music\/Desecresy","name":"Desecresy","@attr":{"rank":"17"},"playcount":"4"},{"mbid":"4236acde-2ce2-441c-a3d4-38d55f1b5474","url":"https:\/\/www.last.fm\/music\/Explosions+in+the+Sky","name":"Explosions in the Sky","@attr":{"rank":"18"},"playcount":"4"},{"mbid":"f6e61750-a6b7-4d88-979b-052345cd0e4a","url":"https:\/\/www.last.fm\/music\/Sturgill+Simpson","name":"Sturgill Simpson","@attr":{"rank":"19"},"playcount":"4"},{"mbid":"69421e11-e4c3-4854-951b-ceab4972e38e","url":"https:\/\/www.last.fm\/music\/Alkaline+Trio","name":"Alkaline Trio","@attr":{"rank":"20"},"playcount":"3"},{"mbid":"f66d378e-d9f0-4c5d-a4b9-0ee1b9fb2e09","url":"https:\/\/www.last.fm\/music\/Anxious","name":"Anxious","@attr":{"rank":"21"},"playcount":"2"},{"mbid":"7e13cd1c-0300-4d03-bd8e-5f86dd99d74f","url":"https:\/\/www.last.fm\/music\/At+the+Drive-In","name":"At the Drive-In","@attr":{"rank":"22"},"playcount":"1"}],"@attr":{"from":"1699272000","user":"coryd_","to":"1699876800"}}} \ No newline at end of file +{ + "charts": [] +} diff --git a/src/_data/json/weekly-artist-charts.json.bak b/src/_data/json/weekly-artist-charts.json.bak new file mode 100644 index 00000000..2ef804f3 --- /dev/null +++ b/src/_data/json/weekly-artist-charts.json.bak @@ -0,0 +1 @@ +{"weeklyartistchart":{"artist":[{"mbid":"0743b15a-3c32-48c8-ad58-cb325350befa","url":"https:\/\/www.last.fm\/music\/blink-182","name":"blink-182","@attr":{"rank":"1"},"playcount":"19"},{"mbid":"aba64937-3334-4c65-90a1-4e6b9d4d7ada","url":"https:\/\/www.last.fm\/music\/Aesop+Rock","name":"Aesop Rock","@attr":{"rank":"2"},"playcount":"18"},{"mbid":"12a9e259-f7cb-4fca-87b1-a6c5fd38c300","url":"https:\/\/www.last.fm\/music\/Hot+Mulligan","name":"Hot Mulligan","@attr":{"rank":"3"},"playcount":"12"},{"mbid":"5c9dd772-a38f-4873-baa8-4b5d9dff3990","url":"https:\/\/www.last.fm\/music\/Spanish+Love+Songs","name":"Spanish Love Songs","@attr":{"rank":"4"},"playcount":"12"},{"mbid":"664c3e0e-42d8-48c1-b209-1efca19c0325","url":"https:\/\/www.last.fm\/music\/The+National","name":"The National","@attr":{"rank":"5"},"playcount":"12"},{"mbid":"a521f1a8-a949-4dcf-ab33-94596cb02787","url":"https:\/\/www.last.fm\/music\/Militarie+Gun","name":"Militarie Gun","@attr":{"rank":"6"},"playcount":"11"},{"mbid":"3ac482b8-1494-4071-a0e9-f192f9d2c2b0","url":"https:\/\/www.last.fm\/music\/Built+to+Spill","name":"Built to Spill","@attr":{"rank":"7"},"playcount":"10"},{"mbid":"6e7aea5b-de9f-4118-ae32-ddea8198864a","url":"https:\/\/www.last.fm\/music\/Dogleg","name":"Dogleg","@attr":{"rank":"8"},"playcount":"10"},{"mbid":"20244d07-534f-4eff-b4d4-930878889970","url":"https:\/\/www.last.fm\/music\/Taylor+Swift","name":"Taylor Swift","@attr":{"rank":"9"},"playcount":"9"},{"mbid":"c16dcdae-a651-42c1-aff8-edda0f463157","url":"https:\/\/www.last.fm\/music\/Soft+Kill","name":"Soft Kill","@attr":{"rank":"10"},"playcount":"8"},{"mbid":"552cd2a3-ac51-464d-8222-dcdbb08a8d2d","url":"https:\/\/www.last.fm\/music\/Tomb+Mold","name":"Tomb Mold","@attr":{"rank":"11"},"playcount":"8"},{"mbid":"","url":"https:\/\/www.last.fm\/music\/Inanna","name":"Inanna","@attr":{"rank":"12"},"playcount":"7"},{"mbid":"","url":"https:\/\/www.last.fm\/music\/AFI","name":"AFI","@attr":{"rank":"13"},"playcount":"6"},{"mbid":"","url":"https:\/\/www.last.fm\/music\/home+is+where","name":"home is where","@attr":{"rank":"14"},"playcount":"6"},{"mbid":"03f9e6f0-7c7f-4fd6-a47f-f0b0425f314b","url":"https:\/\/www.last.fm\/music\/Mis%C3%BEyrming","name":"Misþyrming","@attr":{"rank":"15"},"playcount":"6"},{"mbid":"4ef06a0d-b8d1-42b4-aff8-06f223306cdb","url":"https:\/\/www.last.fm\/music\/Cloud+Rat","name":"Cloud Rat","@attr":{"rank":"16"},"playcount":"5"},{"mbid":"67d1433c-6354-4fb4-bb57-bd21c4904eed","url":"https:\/\/www.last.fm\/music\/Desecresy","name":"Desecresy","@attr":{"rank":"17"},"playcount":"4"},{"mbid":"4236acde-2ce2-441c-a3d4-38d55f1b5474","url":"https:\/\/www.last.fm\/music\/Explosions+in+the+Sky","name":"Explosions in the Sky","@attr":{"rank":"18"},"playcount":"4"},{"mbid":"f6e61750-a6b7-4d88-979b-052345cd0e4a","url":"https:\/\/www.last.fm\/music\/Sturgill+Simpson","name":"Sturgill Simpson","@attr":{"rank":"19"},"playcount":"4"},{"mbid":"69421e11-e4c3-4854-951b-ceab4972e38e","url":"https:\/\/www.last.fm\/music\/Alkaline+Trio","name":"Alkaline Trio","@attr":{"rank":"20"},"playcount":"3"},{"mbid":"f66d378e-d9f0-4c5d-a4b9-0ee1b9fb2e09","url":"https:\/\/www.last.fm\/music\/Anxious","name":"Anxious","@attr":{"rank":"21"},"playcount":"2"},{"mbid":"7e13cd1c-0300-4d03-bd8e-5f86dd99d74f","url":"https:\/\/www.last.fm\/music\/At+the+Drive-In","name":"At the Drive-In","@attr":{"rank":"22"},"playcount":"1"}],"@attr":{"from":"1699272000","user":"coryd_","to":"1699876800"}}} \ No newline at end of file diff --git a/src/_data/weeklyArtistChart.js b/src/_data/weeklyArtistChart.js index 68d7f775..897b9a24 100644 --- a/src/_data/weeklyArtistChart.js +++ b/src/_data/weeklyArtistChart.js @@ -1,22 +1,22 @@ -const chartData = require('./json/weekly-artist-charts.json') - -module.exports = async function () { - const artists = chartData['weeklyartistchart']['artist'].splice(0, 8) - const date = parseInt(chartData['weeklyartistchart']['@attr']['to']) * 1000 - let content = 'My top artists for the week: ' - artists.forEach((artist, index) => { - content += `${artist['name']} @ ${artist['playcount']} play${ - parseInt(artist['playcount']) > 1 ? 's' : '' - }` - if (index !== artists.length - 1) content += ', ' - }) - content += ' #Music #LastFM' - return [ - { - title: content, - url: `https://coryd.dev/now?ts=${date}`, - date: new Date(date), - description: 'My top artists for the week as a feed item.

', - }, - ] -} +// const chartData = require('./json/weekly-artist-charts.json') +// +// module.exports = async function () { +// const artists = chartData['weeklyartistchart']['artist'].splice(0, 8) +// const date = parseInt(chartData['weeklyartistchart']['@attr']['to']) * 1000 +// let content = 'My top artists for the week: ' +// artists.forEach((artist, index) => { +// content += `${artist['name']} @ ${artist['playcount']} play${ +// parseInt(artist['playcount']) > 1 ? 's' : '' +// }` +// if (index !== artists.length - 1) content += ', ' +// }) +// content += ' #Music #LastFM' +// return [ +// { +// title: content, +// url: `https://coryd.dev/now?ts=${date}`, +// date: new Date(date), +// description: 'My top artists for the week as a feed item.

', +// }, +// ] +// }