-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspotify-clipper.json
More file actions
12 lines (12 loc) · 2.62 KB
/
spotify-clipper.json
File metadata and controls
12 lines (12 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
{
"schemaVersion": "0.1.0",
"name": "Spotify",
"behavior": "create",
"noteContentFormat": "<%* \nconst url = '{{ url }}';\nconst regex = /https:\\/\\/open\\.spotify\\.com\\/([a-z]*)\\/(.*)/g;\nconst extracts = await regex.exec(url);\nconst type = extracts[1];\nconst id = extracts[2];\nlet response = null;\nconst mediaData = {};\ntry {\n\tswitch (type) {\n\t case 'track': {\n\t\tresponse = await window.spotifysdk.tracks.get(id);\n\t\tconsole.log(response);\n\t\tbreak;\n\t }\n\t case 'album': {\n\t\tresponse = await window.spotifysdk.albums.get(id);\n\t\tconsole.log(response);\n\t\tbreak;\n\t }\n\t case 'artist': {\n\t\tresponse = await window.spotifysdk.artists.get(id);\n\t\tconsole.log(response);\n\t\tbreak;\n\t }\n\t case 'playlist': {\n\t\tresponse = await window.spotifysdk.playlists.getPlaylist(id);\n\t\tconsole.log(response);\n\t\tbreak;\n\t }\n\t case 'episode': {\n\t\tresponse = await window.spotifysdk.episodes.get(id);\n\t\tmediaData.url = response.external_urls.spotify;\n\t\tmediaData.author = response.show.publisher;\n\t\tmediaData.title = response.name;\n\t\tmediaData.publishedDate = response.release_date;\n\t\tmediaData.description = response.description;\n\t\tbreak;\n\t }\n\t case 'show': {\n\t\tresponse = await window.spotifysdk.shows.get(id);\n\t\tmediaData.url = response.external_urls.spotify;\n\t\tmediaData.author = response.publisher;\n\t\tmediaData.title = response.name;\n\t\tmediaData.publishedDate = response.episodes.items[0].release_date\n\t\tmediaData.description = response.description\n\t\tbreak;\n\t }\n\t default:\n\t\tresponse = 'There seems to be a problem with this ressource';\n\t}\n} catch (error) {\n\tresponse = 'There seems to be a problem with this ressource :' + error;\n}\nif (typeof(response) === 'string') {\n tR = response;\n} else {\ntR += `---\nsource: ${mediaData.url}\ncreatedAt: 2025-01-20T14:18:23+01:00\nauthor: ${mediaData.author}\nname: \"${mediaData.title}\"\nformat: ${type}\npublishedAt: ${mediaData.publishedDate}\n---\n## ${mediaData.title}\n[](${mediaData.url})\n\n${mediaData.description}`;\n}\n%>\n## Notes\n",
"properties": [],
"triggers": [
"https://open.spotify.com/"
],
"noteNameFormat": "{{date|date:YYYY-MM-DD}} {{time|date:HH-mm}} - SPOTIFY {{selector:#main > div > div.ZQftYELq0aOsg6tPbVbV > div.jEMA2gVoLgPQqAFrPhFw > div > div.main-view-container__scroll-node.main-view-container__scroll-node--offset-topbar > div:nth-child(2) > div > main > section > div.NXiYChVp4Oydfxd7rT5r.JYKKZFIXuf9lIHVeszuS > div.iWTIFTzhRZT0rCD0_gOK.contentSpacing > div.RP2rRchy4i8TIp1CTmb7 > span.rEN7ncpaUeSGL9z0NGQR > h1|safe_name}}",
"path": "Lab/Inbox"
}