1 JsOsaDAS1.001.00bplist00Ñ
\ 1\ 2Vscript_
\11\10rconst internals = {
4 musicFolder: "155 - music"
6 kURLParser: /https?:\/\/[^\s'"><]+/gi,
11 kMatcher: /youtube.com\/embed\/([^?]+)/,
13 return url.match(this.kMatcher);
16 return 'youtube_embed:' + url.match(this.kMatcher)[1];
21 kMatcher: /youtube.com\/watch.*v=([^&]+)/,
23 return url.match(this.kMatcher);
26 return 'youtube_video:' + url.match(this.kMatcher)[1];
31 kMatcher: /youtube.com\/playlist.*list=([^&]+)/,
33 return url.match(this.kMatcher);
36 return 'youtube_playlist:' + url.match(this.kMatcher)[1];
42 return url.match(/youtube/);
45 return '!!!!!!!!!!!!!!!!!:' + url
48 // bandcamp embedded track
50 kMatcher: /bandcamp.*EmbeddedPlayer.*track=([0-9]+)/,
52 return url.match(this.kMatcher);
55 return 'bc_embed_track:' + url.match(this.kMatcher)[1];
58 // bandcamp embedded album
60 kMatcher: /bandcamp.*EmbeddedPlayer.*album=([0-9]+)/,
62 return url.match(this.kMatcher);
65 return 'bc_embed_album:' + url.match(this.kMatcher)[1];
71 return url.match(/https?:\/\/([^.]+)\.bandcamp\.com\/album/);
74 return 'bc_album:' + url
80 return url.match(/https?:\/\/([^.]+)\.bandcamp\.com\/track/);
83 return 'bc_track:' + url
88 kMatcher: /https?:\/\/([^.]+)\.bandcamp.com(?:\/music)?/,
90 return url.match(this.kMatcher);
93 return 'bc_artist:' + url.match(this.kMatcher)[1];
99 return url.match(/bandcamp\.com/);
102 return '!!!!!!!!!!!!!!!!!:' + url
107 kMatcher: /soundcloud.com\/player.*tracks%2F([^&]+)/,
109 return url.match(this.kMatcher);
112 return 'sc_player: ' + url.match(this.kMatcher)[1]
117 kMatcher: /soundcloud.com\/([^\/]+)\/([^\/]+)/,
119 return url.match(this.kMatcher);
122 return 'soundcloud_track: ' + url.match(this.kMatcher)[2]
125 // soundcloud unmatched
128 return url.match(/soundcloud/);
131 return '!!!!!!!!!!!!!!!!!:' + url
136 kMatcher: /spotify.com\/embed\/track\/([^?]+)/,
138 return url.match(this.kMatcher);
141 return 'sp_embed:' + url.match(this.kMatcher)[1];
147 return url.match(/spotify/);
150 return '!!!!!!!!!!!!!!!!!:' + url
155 extractURLsFromFeeds() {
156 const app = Application("NetNewsWire");
157 app.includeStandardAdditions = true;
159 let account = app.accounts.whose({name: internals.config.account})[0];
160 let musicFolder = account.folders.whose({name: internals.config.musicFolder})[0];
161 const feeds = musicFolder.webfeeds();
165 for (const feed of feeds) {
166 const articles = feed.articles();
168 for (const article of articles) {
169 console.log(article.title())
170 const html = article.html();
171 const extractedURLs = html.match(internals.kURLParser) || [];
172 urls.push(...extractedURLs)
179 extractSongsFromURLs(urls) {
184 for (const strategy of internals.strategies) {
185 if (strategy.canHandle(url)) {
186 songs.push(strategy.handle(url))
196 const run = function () {
198 const urls = internals.extractURLsFromFeeds();
199 const songs = internals.extractSongsFromURLs(urls);