From 8be6308dd417c7b32d2643fd395eecf1b8906f8c Mon Sep 17 00:00:00 2001 From: patrickkfkan Date: Mon, 15 Feb 2021 18:26:37 +0800 Subject: [PATCH] Revise getReleasesByTag() --- README.md | 5 +- examples/getReleasesByTag.js | 5 +- examples/getReleasesByTag_output.txt | 316 ++++++++++++++------------- lib/index.js | 69 ++++-- 4 files changed, 215 insertions(+), 180 deletions(-) diff --git a/README.md b/README.md index a4e98bf..5431140 100644 --- a/README.md +++ b/README.md @@ -221,13 +221,13 @@ Fetches information about the tag referred to by `tagUrl`. [**Example**](examples/getReleasesByTag.js) ([output](examples/getReleasesByTag_output.txt)) -Fetches releases matching the tag referred to by `tagUrl` (note: tag is overridable by `params.filter.tags`). +Fetches releases matching the tag referred to by `tagUrl`. - `tagUrl` - `params` (optional) - filters: - location - - tags: array of tag values to match + - tags: array of tag values to match, in addition to the one referred to by `tagUrl`. - sort - format - page (1 if omitted) @@ -236,6 +236,7 @@ Fetches releases matching the tag referred to by `tagUrl` (note: tag is overrida - `options` (optional) - imageFormat + - useHardcodedDefaultFilters: if `true`, use hardcoded default values for filters not specified in `params.filters`. If `false` or unspecified, default filter values will be obtained by calling `getReleasesByTagFilterOptions()` (extra query means slower performance). ### `getReleasesByTagFilterOptions(tagUrl)` diff --git a/examples/getReleasesByTag.js b/examples/getReleasesByTag.js index b4eb9af..34cd0ee 100644 --- a/examples/getReleasesByTag.js +++ b/examples/getReleasesByTag.js @@ -5,14 +5,15 @@ const tagUrl = 'https://bandcamp.com/tag/dark-ambient'; const params = { filters: { - tags: [ 'dark-ambient', 'electronica' ], + tags: [ 'electronica' ], sort: 'random' }, page: 2 }; const options = { - imageFormat: 2 + imageFormat: 2, + useHardcodedDefaultFilters: true } bcfetch.getReleasesByTag(tagUrl, params, options).then( results => { diff --git a/examples/getReleasesByTag_output.txt b/examples/getReleasesByTag_output.txt index 993e668..630a235 100644 --- a/examples/getReleasesByTag_output.txt +++ b/examples/getReleasesByTag_output.txt @@ -1,205 +1,207 @@ { items: [ { type: 'album', - name: 'Gold For Iron (Remastered)', - url: 'https://subculturerecords.bandcamp.com/album/gold-for-iron-remastered', - imageUrl: 'https://f4.bcbits.com/img/a160176114_2.jpg', + name: 'Deep Like My Side', + url: 'https://yasharam.bandcamp.com/album/deep-like-my-side', + imageUrl: 'https://f4.bcbits.com/img/a1566777509_2.jpg', + genre: 'ambient', + artist: { name: 'Yashar AM', url: 'https://yasharam.bandcamp.com' }, + featuredTrack: + { name: 'I Dont Tell To Her/Him', + streamUrl: 'https://t4.bcbits.com/stream/f1e54272e8642112bee427a18665972f/mp3-128/1494281343?p=0&ts=1613471183&t=fdac0c8c2efc15a3dfe9ee88c1cf3055e756b87b&token=1613471183_dee5b6809da736c5f5efd937d05024a99247c3ea' } }, + { type: 'album', + name: 'Steel Sky', + url: 'https://dryeyes.bandcamp.com/album/steel-sky', + imageUrl: 'https://f4.bcbits.com/img/a4190860065_2.jpg', + genre: 'experimental', + artist: { name: 'Dry Eyes', url: 'https://dryeyes.bandcamp.com' }, + featuredTrack: + { name: 'Steel Sky', + streamUrl: 'https://t4.bcbits.com/stream/95947052b9ff44734f0da62051afed62/mp3-128/2914403443?p=0&ts=1613471183&t=ba80a3bf8143308e1df642c86e87ce6437fb28ca&token=1613471183_4145d1b1a7e9006cbc32c5f7f14ba20e3e87d7c6' } }, + { type: 'album', + name: 'Wavelabs', + url: 'https://lihjx.bandcamp.com/album/wavelabs', + imageUrl: 'https://f4.bcbits.com/img/a1449720309_2.jpg', + genre: 'experimental', + artist: { name: 'LihjX', url: 'https://lihjx.bandcamp.com' }, + featuredTrack: + { name: 'B.O.C. Transmissions', + streamUrl: 'https://t4.bcbits.com/stream/4b6b119420cdd3e2e1dbf38734477f3b/mp3-128/1306482052?p=0&ts=1613471183&t=c8a2d23dd13edf0447cfbebd9c54dfb44f1b0605&token=1613471183_8d63605a94b4d4a8a639f91460ec4ad2b745eaaf' } }, + { type: 'album', + name: 'Loose Ends', + url: 'https://subculturerecords.bandcamp.com/album/loose-ends', + imageUrl: 'https://f4.bcbits.com/img/a31742624_2.jpg', genre: 'electronic', artist: - { name: 'Carlos Perón', + { name: 'Piston Damp', url: 'https://subculturerecords.bandcamp.com' }, featuredTrack: - { name: 'Motorman', - streamUrl: 'https://t4.bcbits.com/stream/b48679497b6cf2b6323b9fb7ee05ab7f/mp3-128/1299531576?p=0&ts=1613319451&t=66923eb047d477402136a331288856a572632df7&token=1613319451_16077a38922610b0a9792f5aae1a21d679169bed' } }, + { name: 'Loose Ends', + streamUrl: 'https://t4.bcbits.com/stream/3abd561db48a70f82c18445293ba76b7/mp3-128/4177569166?p=0&ts=1613471183&t=30c24b8d53cb18ee148c019b0b007db0b1cb9e9f&token=1613471183_7526a19206f0fc8725c3bfc8adef393e6e0f0e33' } }, { type: 'album', - name: 'Coalition', - url: 'https://ddawg1.bandcamp.com/album/coalition', - imageUrl: 'https://f4.bcbits.com/img/a489009199_2.jpg', + name: 'Left Behind', + url: 'https://wardove.bandcamp.com/album/left-behind', + imageUrl: 'https://f4.bcbits.com/img/a1467280380_2.jpg', genre: 'electronic', - artist: { name: 'DDAWG', url: 'https://ddawg1.bandcamp.com' }, + artist: { name: 'DJ Wardove', url: 'https://wardove.bandcamp.com' }, featuredTrack: - { name: 'Coalition', - streamUrl: 'https://t4.bcbits.com/stream/38dbaf0431a92c65b8bfec58eecdbd72/mp3-128/2901122015?p=0&ts=1613319451&t=b4507287875449d99a5e4a04511c68477779075d&token=1613319451_44d71f1e9b87697721ac8b7ed4e519bdb4a6b82e' } }, + { name: 'Wild Doves', + streamUrl: 'https://t4.bcbits.com/stream/05760ab34531b1419e564a14af86e3fc/mp3-128/518128632?p=0&ts=1613471183&t=7e4e7f1c544c8f32681a2bc914cde8727d4eaf7a&token=1613471183_5653041a82a1fdc581df7b9319f40cfbea12c240' } }, { type: 'album', - name: 'ICS 2013 Sessions Volume I: Second', - url: 'https://xocp.bandcamp.com/album/ics-2013-sessions-volume-i-second', - imageUrl: 'https://f4.bcbits.com/img/a20012955_2.jpg', + name: 'acouasm', + url: 'https://algorhythms-co-uk.bandcamp.com/album/acouasm', + imageUrl: 'https://f4.bcbits.com/img/a2642836549_2.jpg', + genre: 'experimental', + artist: { name: 'algo', url: 'https://algorhythms-co-uk.bandcamp.com' }, + featuredTrack: + { name: 'CNX', + streamUrl: 'https://t4.bcbits.com/stream/b858b5773573ac1c378e3fef99c105b9/mp3-128/677954387?p=0&ts=1613471183&t=8880fe5d170818108c913a8fd23fd226c5bee7de&token=1613471183_d15c7b71b81afa36a3e1763e347119483972e3c4' } }, + { type: 'album', + name: 'SKY BOY - Remember [Statics 9]', + url: 'https://staticsmusic.bandcamp.com/album/sky-boy-remember-statics-9', + imageUrl: 'https://f4.bcbits.com/img/a665632189_2.jpg', genre: 'electronic', - artist: { name: 'xocp', url: 'https://xocp.bandcamp.com' }, + artist: { name: 'SKY BOY', url: 'https://staticsmusic.bandcamp.com' }, featuredTrack: - { name: 'We Must Walk In The Shadows', - streamUrl: 'https://t4.bcbits.com/stream/35c3a24476c86f90dc33bef462067300/mp3-128/3969636275?p=0&ts=1613319451&t=5d9ea1220741a0b72b8f163f5f812fc63300f6d5&token=1613319451_2fc7085d012a06c8a8f8a9af10b2c1a5a011aad6' } }, + { name: 'SKY BOY - Remember [Statics 9]', + streamUrl: 'https://t4.bcbits.com/stream/f1fec39bb84cdfee18abf474a771a3d8/mp3-128/168865234?p=0&ts=1613471183&t=0c20cb7f01e3f748730c7915a97948271d62c7d6&token=1613471183_b7fb2404ee4c859c4f2b77fef2910081af68039d' } }, { type: 'album', - name: 'Nocturne', - url: 'https://zoharum.bandcamp.com/album/nocturne', - imageUrl: 'https://f4.bcbits.com/img/a403739929_2.jpg', + name: '0013', + url: 'https://dystopiasymphonia.bandcamp.com/album/0013', + imageUrl: 'https://f4.bcbits.com/img/a3002401502_2.jpg', genre: 'electronic', - artist: { name: 'Aquavoice', url: 'https://zoharum.bandcamp.com' }, + artist: + { name: 'Dystopia Symphonia', + url: 'https://dystopiasymphonia.bandcamp.com' }, featuredTrack: - { name: 'Fish Dreams', - streamUrl: 'https://t4.bcbits.com/stream/ff0b13463e7a632b8d9a2f37d53f6042/mp3-128/3924307548?p=0&ts=1613319451&t=4e4acd78e246f70b9566700aabc2d44a5a358daa&token=1613319451_673cec76ce331e6a541b549bb804224ef0e45c4f' } }, + { name: 'This Is What Is Coming', + streamUrl: 'https://t4.bcbits.com/stream/6d85724f193bc588deaedecf0366c3ce/mp3-128/1847089218?p=0&ts=1613471183&t=33c92ac1dd3316bc825b3fe2ffc0ea8590bedd0f&token=1613471183_5721997464b20d3b77be8ed9853f331846d7712e' } }, { type: 'album', - name: 'III', - url: 'https://audiophyla.bandcamp.com/album/iii', - imageUrl: 'https://f4.bcbits.com/img/a948523996_2.jpg', + name: 'Cold Mountain', + url: 'https://oneambient4.bandcamp.com/album/cold-mountain', + imageUrl: 'https://f4.bcbits.com/img/a3680767099_2.jpg', + genre: 'ambient', + artist: + { name: 'David Gordon, aka OneAmbient4', + url: 'https://oneambient4.bandcamp.com' }, + featuredTrack: + { name: 'Frozen', + streamUrl: 'https://t4.bcbits.com/stream/24727e1e3f4e3daf051cdeaccc3d4196/mp3-128/3301227742?p=0&ts=1613471183&t=777a4488a6d9daf05e8e6eb4d573e5b9355ecd22&token=1613471183_7a54d52492af2f52142c1afb6ad4b2f4c44ecc28' } }, + { type: 'album', + name: 'Erotikon', + url: 'https://deutschnepal.bandcamp.com/album/erotikon', + imageUrl: 'https://f4.bcbits.com/img/a3476983383_2.jpg', genre: 'experimental', artist: - { name: 'Free Mycelial Underground', - url: 'https://audiophyla.bandcamp.com' }, + { name: 'Deutsch Nepal', + url: 'https://deutschnepal.bandcamp.com' }, featuredTrack: - { name: 'Heart of the Mechanism', - streamUrl: 'https://t4.bcbits.com/stream/93afb4dcf2956206166cc43e3137e056/mp3-128/1827954244?p=0&ts=1613319451&t=65e730986ad7cfe81617511874bd6fa03a66fda1&token=1613319451_004b5c88b262e72a37011ada020cb42bc339a483' } }, + { name: 'Heartbomb', + streamUrl: 'https://t4.bcbits.com/stream/2dc60b33e0ab7e45695f9f032d3a9528/mp3-128/3402533368?p=0&ts=1613471183&t=ad80e245ce3163be6eecd2e98de1815e4c4cf3c6&token=1613471183_335afdd008c84bb4fc81ddb07c64803146cb7896' } }, { type: 'album', - name: 'Forms', - url: 'https://gayedevice.bandcamp.com/album/forms', - imageUrl: 'https://f4.bcbits.com/img/a3176133867_2.jpg', - genre: 'electronic', - artist: - { name: 'THE GAYE DEVICE', - url: 'https://gayedevice.bandcamp.com' }, - featuredTrack: - { name: 'Under Old Earth', - streamUrl: 'https://t4.bcbits.com/stream/c9d85c8d09eb7fae7123093f3a9040e9/mp3-128/2296902800?p=0&ts=1613319451&t=16e48fcb34371f4082a79ee2c8999d7fdef0f189&token=1613319451_cd781a8197b2f484a53c0f56525ec4e372d34620' } }, - { type: 'album', - name: 'Erotigasm! EP', - url: 'https://erotigasm.bandcamp.com/album/erotigasm-ep', - imageUrl: 'https://f4.bcbits.com/img/a282613426_2.jpg', - genre: 'electronic', - artist: { name: 'Erotigasm!', url: 'https://erotigasm.bandcamp.com' }, - featuredTrack: - { name: 'Sleepless, Endless', - streamUrl: 'https://t4.bcbits.com/stream/debe51a076743ebbbf795b140059bf86/mp3-128/140183911?p=0&ts=1613319451&t=8c2dbe3edfd66490f0322f40ff27811e6d8bc4f1&token=1613319451_3950d1d5385a55521bf66527d8ce6e91ecc3dbc9' } }, - { type: 'album', - name: 'Alchemical Congress (SBKWDIGI001)', - url: 'https://separatedbeats.bandcamp.com/album/alchemical-congress-sbkwdigi001', - imageUrl: 'https://f4.bcbits.com/img/a3954752144_2.jpg', + name: 'Invasive Species', + url: 'https://identityknown.bandcamp.com/album/invasive-species', + imageUrl: 'https://f4.bcbits.com/img/a2557828338_2.jpg', genre: 'ambient', artist: - { name: 'B. Ashra & Ricky Deadking', - url: 'https://separatedbeats.bandcamp.com' }, + { name: 'Identity Known', + url: 'https://identityknown.bandcamp.com' }, featuredTrack: - { name: 'Shaman', - streamUrl: 'https://t4.bcbits.com/stream/91653392b453c9eeeb193411bd3a29a4/mp3-128/3914725080?p=0&ts=1613319451&t=ab887f92db6198ad3d418b3089718da84bad66bf&token=1613319451_8a91f9e38d03c95a8fa907ea8031a550217add37' } }, + { name: 'As it wakes', + streamUrl: 'https://t4.bcbits.com/stream/b7bae21595959c6d3e05e776de4390e5/mp3-128/947704421?p=0&ts=1613471183&t=77764798f21a9dd57b0c149fe6fc2c7d5a775743&token=1613471183_9fb10fa60a78ca0774063601b367333e635b7c31' } }, { type: 'album', - name: 'MILIEU : MUSIC FOR THE PLANETS - EXTRA -', - url: 'https://ealabo.bandcamp.com/album/milieu-music-for-the-planets-extra', - imageUrl: 'https://f4.bcbits.com/img/a1086708909_2.jpg', + name: '来 て', + url: 'https://revolutiongirl.bandcamp.com/album/--29', + imageUrl: 'https://f4.bcbits.com/img/a1255187499_2.jpg', genre: 'ambient', - artist: { name: 'Noght', url: 'https://ealabo.bandcamp.com' }, + artist: { name: '革 命 少 女', url: 'https://revolutiongirl.bandcamp.com' }, featuredTrack: - { name: 'Merkuro#2', - streamUrl: 'https://t4.bcbits.com/stream/9da588698480a4e388ba3f098bc506b7/mp3-128/3318433630?p=0&ts=1613319451&t=fc9e0cbe9ebe10f90839fa3e69fbfc27e4c47fce&token=1613319451_a262f15371deda8c019fa9f143c5400ad3f294bd' } }, + { name: '夜歩くアクティビティー', + streamUrl: 'https://t4.bcbits.com/stream/e761c78cedaac7ce6abdc3e2db46c92f/mp3-128/2568868346?p=0&ts=1613471183&t=1060bcc6abdec73605f2c0e666af0dcf91a73437&token=1613471183_95449acac84baaee8ff2f1223869b0d97fb0a91b' } }, { type: 'album', - name: 'rådiövölnå - raw artefacts', - url: 'https://rawrussian.bandcamp.com/album/r-di-v-ln-raw-artefacts', - imageUrl: 'https://f4.bcbits.com/img/a2489691060_2.jpg', - genre: 'electronic', - artist: { name: 'Raw Russian', url: 'https://rawrussian.bandcamp.com' }, - featuredTrack: - { name: 'Untitled (intro)', - streamUrl: 'https://t4.bcbits.com/stream/5824bf7e0b506b25cf07c1a05ac54182/mp3-128/112362465?p=0&ts=1613319451&t=dd7d9b1e9bf259540d23c5bdb4f77dd956576e5c&token=1613319451_ac10914b9c94349a3e07e278ceeab8f1ee547ec2' } }, - { type: 'album', - name: 'DIE FORM ÷ MUSIQUE CONCRÈTE - "Cinema Obscura"', - url: 'https://dieform.bandcamp.com/album/die-form-musique-concr-te-cinema-obscura', - imageUrl: 'https://f4.bcbits.com/img/a737200792_2.jpg', - genre: 'electronic', - artist: - { name: 'DIE FORM Solo-project', - url: 'https://dieform.bandcamp.com' }, - featuredTrack: - { name: 'Melodia Melancolica', - streamUrl: 'https://t4.bcbits.com/stream/f95cd4418ec4a89f667cda2e760ac81b/mp3-128/2629471101?p=0&ts=1613319451&t=3d611cb6ffd4c4aa1339130d3057e54841ffec4e&token=1613319451_cf34ca7f094c386e13163b804311c6bb4a156eea' } }, - { type: 'album', - name: 'cloudform', - url: 'https://zarr.bandcamp.com/album/cloudform', - imageUrl: 'https://f4.bcbits.com/img/a1131211662_2.jpg', + name: 'Moments We Spent Together | Marigold Fields', + url: 'https://pitp.bandcamp.com/album/moments-we-spent-together-marigold-fields', + imageUrl: 'https://f4.bcbits.com/img/a298764323_2.jpg', genre: 'ambient', - artist: { name: 'zarr.', url: 'https://zarr.bandcamp.com' }, + artist: { name: 'Endless Melancholy', url: 'https://pitp.bandcamp.com' }, featuredTrack: - { name: 'Cloudform', - streamUrl: 'https://t4.bcbits.com/stream/a10f555f50d68e65f86be70fa45432a6/mp3-128/570854209?p=0&ts=1613319451&t=72ef9333ed063e3636eaa9abcf7aae37714b4a21&token=1613319451_624d91cdab5a56cb9de566d087ce0e51b0a8da9e' } }, + { name: 'Moments We Spent Together', + streamUrl: 'https://t4.bcbits.com/stream/8d58d77f0a5209a66d4761540a7de080/mp3-128/2858968173?p=0&ts=1613471183&t=dd892b0ba831121e415a22467c44023f349029f5&token=1613471183_9e67df9978d2004493553cd1f7ed045d48d35b13' } }, { type: 'album', - name: 'Never Too Late', - url: 'https://tomorrowentertainment.bandcamp.com/album/never-too-late', - imageUrl: 'https://f4.bcbits.com/img/a3490301505_2.jpg', + name: 'the ways of fate', + url: 'https://magnetismeobscur.bandcamp.com/album/the-ways-of-fate', + imageUrl: 'https://f4.bcbits.com/img/a3299271599_2.jpg', genre: 'electronic', artist: - { name: 'Jetix Television', - url: 'https://tomorrowentertainment.bandcamp.com' }, + { name: 'magnetisme obscur', + url: 'https://magnetismeobscur.bandcamp.com' }, featuredTrack: - { name: 'dear melancholy', - streamUrl: 'https://t4.bcbits.com/stream/1721f969d53df77c9f81aeb50bd98e5c/mp3-128/2530021139?p=0&ts=1613319451&t=a829ede8dd7724e4fe3e0ee32960341f9414dd89&token=1613319451_d2f2a8c77805b9f876f90fb160829147e49f3be8' } }, + { name: 'lenom', + streamUrl: 'https://t4.bcbits.com/stream/e33e5aaa60953e69cc18d056bedbd6b7/mp3-128/2719332497?p=0&ts=1613471183&t=aed87682eabc1df68eaa01929dfbd381b01e6e24&token=1613471183_fb04f8a4f2e5fc6e515ec0fcc3130f57c9c6d500' } }, { type: 'album', - name: 'Rising Demons', - url: 'https://noiarecords.bandcamp.com/album/rising-demons', - imageUrl: 'https://f4.bcbits.com/img/a1034772939_2.jpg', - genre: 'electronic', - artist: { name: 'NoizyKnobs', url: 'https://noiarecords.bandcamp.com' }, - featuredTrack: - { name: 'Suspense', - streamUrl: 'https://t4.bcbits.com/stream/3e0bc73eea3fdf45ca13b5790078343a/mp3-128/976482763?p=0&ts=1613319451&t=860a015a4c86151eeaaeb0ed3d6e441e99ee8f6c&token=1613319451_cec6989f6696446a042aa98ecfcffde6426c1f7a' } }, - { type: 'album', - name: 'Whispers Of The Future Vol. 03', - url: 'https://subculturerecords.bandcamp.com/album/whispers-of-the-future-vol-03', - imageUrl: 'https://f4.bcbits.com/img/a250873842_2.jpg', - genre: 'electronic', + name: 'Renaissance of Malady', + url: 'https://bleedingkumari.bandcamp.com/album/renaissance-of-malady', + imageUrl: 'https://f4.bcbits.com/img/a703289618_2.jpg', + genre: 'experimental', artist: - { name: 'Various Artists', - url: 'https://subculturerecords.bandcamp.com' }, + { name: 'Bleeding Kumari', + url: 'https://bleedingkumari.bandcamp.com' }, featuredTrack: - { name: 'Embrace (Club Edit)', - streamUrl: 'https://t4.bcbits.com/stream/182566291da60f614bc5b542e45eebb7/mp3-128/3157616160?p=0&ts=1613319451&t=93d567831e874f295e5c87f06a746b6909b59f67&token=1613319451_1a59591f508e8fc713ae63533f3d1cacdf690e74' } }, + { name: 'The Bent Pyramid', + streamUrl: 'https://t4.bcbits.com/stream/66ba5e61639f376ba0f2a57eecb3908d/mp3-128/2499644387?p=0&ts=1613471183&t=493d9c4e03491067ed39d72a84a5dc255287d967&token=1613471183_443e5f37130858a4b4646a0bd3f81182a4b98f82' } }, { type: 'album', - name: 'ARCHITEKT "abstract sky" EP', - url: 'https://managarmproductions.bandcamp.com/album/architekt-abstract-sky-ep', - imageUrl: 'https://f4.bcbits.com/img/a1588223258_2.jpg', + name: 'Buried I', + url: 'https://mercyry.bandcamp.com/album/buried-i', + imageUrl: 'https://f4.bcbits.com/img/a1209083801_2.jpg', + genre: 'electronic', + artist: { name: 'Mercyry', url: 'https://mercyry.bandcamp.com' }, + featuredTrack: + { name: 'Dissipation', + streamUrl: 'https://t4.bcbits.com/stream/8628fddc2d752418a73e0eea21ec1c22/mp3-128/1593388761?p=0&ts=1613471183&t=e2953792420070effb38e4b749c4ff6a8cbf2e33&token=1613471183_6b45b33ff4c47364111b9397095f0072804578bd' } }, + { type: 'album', + name: 'The Unraveling Mind', + url: 'https://downloadmusic.mortiis.com/album/the-unraveling-mind', + imageUrl: 'https://f4.bcbits.com/img/a2125585247_2.jpg', genre: 'metal', - artist: - { name: 'MANAGARM productions', - url: 'https://managarmproductions.bandcamp.com' }, + artist: { name: 'Mortiis', url: 'https://downloadmusic.mortiis.com' }, featuredTrack: - { name: 'Dead Horizon', - streamUrl: 'https://t4.bcbits.com/stream/310eaa4f7647fef5c4d152df49cf7fdb/mp3-128/2477193693?p=0&ts=1613319451&t=c7de8b90a77e130f5bcaa8cd578b49230861a96d&token=1613319451_cccddf7895ecef422852188f253ef3eb93ef4dc0' } }, + { name: 'Virosus - Silentium', + streamUrl: 'https://t4.bcbits.com/stream/ffffac27df791d768213b2dab325a15a/mp3-128/1110628764?p=0&ts=1613471183&t=c3217468704eecf5f0b0f107d24e31496fa94300&token=1613471183_1576d5b13c2806455bd22b546cae5bae55582660' } }, { type: 'album', - name: 'Compilation #4', - url: 'https://reeveswork.bandcamp.com/album/compilation-4', - imageUrl: 'https://f4.bcbits.com/img/a1979748922_2.jpg', - genre: 'electronic', - artist: { name: 'REEVE', url: 'https://reeveswork.bandcamp.com' }, - featuredTrack: - { name: 'TRK-3', - streamUrl: 'https://t4.bcbits.com/stream/91c4a75eede0a7f35cbb418b38f138b0/mp3-128/117677328?p=0&ts=1613319451&t=24fc37ff3db3cfce55dc401595dda04f4a3bae74&token=1613319451_033350e36b89fde07fda9df73f37c9541a92e31e' } }, - { type: 'album', - name: 'licht und schatten', - url: 'https://ant-zen.bandcamp.com/album/licht-und-schatten', - imageUrl: 'https://f4.bcbits.com/img/a177968411_2.jpg', - genre: 'electronic', - artist: { name: 'telepherique', url: 'https://ant-zen.bandcamp.com' }, - featuredTrack: - { name: 'x-rays', - streamUrl: 'https://t4.bcbits.com/stream/557e83e112b824a2f8b6eed3a3e98529/mp3-128/1944451284?p=0&ts=1613319451&t=960f6cacd00522bc77dad18617da323b532f51f5&token=1613319451_4dce2c53aa6bdcafb86b2b705c28055e483ae648' } }, - { type: 'album', - name: 'Fragments of War', - url: 'https://aliensproduction.bandcamp.com/album/fragments-of-war', - imageUrl: 'https://f4.bcbits.com/img/a1991250924_2.jpg', + name: 'Electronic Methods', + url: 'https://matthewvandenbrook.bandcamp.com/album/electronic-methods', + imageUrl: 'https://f4.bcbits.com/img/a1048848480_2.jpg', genre: 'electronic', artist: - { name: 'Gaping Chasm', - url: 'https://aliensproduction.bandcamp.com' }, + { name: 'Matthew VandenBrook', + url: 'https://matthewvandenbrook.bandcamp.com' }, featuredTrack: - { name: 'Day D', - streamUrl: 'https://t4.bcbits.com/stream/d53dd073edf26d6d54c0781955eb8e5e/mp3-128/1937136742?p=0&ts=1613319451&t=efa8a87f40f074481febac9fc14f24948fdf53bf&token=1613319451_5395ff392cbccd1cd9b46ca9f7b58737db9c0e06' } }, + { name: 'Electronic Methods', + streamUrl: 'https://t4.bcbits.com/stream/6c331ba8bade13255fbabb2d08810ec5/mp3-128/3283087023?p=0&ts=1613471183&t=0d8fee87814b8fadb9e1436dce97b7fb32f9c14c&token=1613471183_4caf81ce81b0ad89809457666e5c69dbb5be7dd4' } }, { type: 'album', - name: 'Dimensions of the Void', - url: 'https://flixology.bandcamp.com/album/dimensions-of-the-void', - imageUrl: 'https://f4.bcbits.com/img/a193115146_2.jpg', - genre: 'soundtrack', - artist: { name: 'Flixology', url: 'https://flixology.bandcamp.com' }, + name: 'Ahera / Ulappa', + url: 'https://onsetaudio.bandcamp.com/album/ahera-ulappa', + imageUrl: 'https://f4.bcbits.com/img/a313449412_2.jpg', + genre: '', + artist: + { name: 'Joonas Aleksi', + url: 'https://onsetaudio.bandcamp.com' }, featuredTrack: - { name: 'Process of Elimination', - streamUrl: 'https://t4.bcbits.com/stream/94d788965fcb472e130c6d721f470e38/mp3-128/2455204824?p=0&ts=1613319451&t=aac2c2dfa0e50ea95228009febf639355c7c0e0e&token=1613319451_8bb5746da876d43ee70d0e02c091edeac0f4ac9d' } } ], + { name: 'Ahera', + streamUrl: 'https://t4.bcbits.com/stream/343e9ded767d04d38df1508ffa245ee8/mp3-128/1571163167?p=0&ts=1613471183&t=0a8579701b3c0c28d1436d56ca410c296a09b6ee&token=1613471183_67e9901738e188f529e83438a2ef519f3050aa7c' } }, + { type: 'album', + name: 'The Faintest Flickering Light: Electronic Experiments, Volume 1', + url: 'https://hebluesrecords.bandcamp.com/album/the-faintest-flickering-light-electronic-experiments-volume-1', + imageUrl: 'https://f4.bcbits.com/img/a179261036_2.jpg', + genre: 'jazz', + artist: + { name: 'Misha Siegfried & His Band', + url: 'https://hebluesrecords.bandcamp.com' }, + featuredTrack: + { name: 'Moody_AF', + streamUrl: 'https://t4.bcbits.com/stream/a4c3ebe9a773f2fc60d7e9a7a1353b79/mp3-128/2984581408?p=0&ts=1613471183&t=52d075f0c5d9e5edbe186191f1e10dfa494fcf40&token=1613471183_3bd94f78f479065de061f729c510a584b312d817' } } ], hasMore: true, filters: - { tags: [ 'dark-ambient', 'electronica' ], + { format: 'all', sort: 'random', - format: 'all', - location: 0 } } + location: 0, + tags: [ 'dark-ambient', 'electronica' ] } } diff --git a/lib/index.js b/lib/index.js index 6c42572..78f19eb 100644 --- a/lib/index.js +++ b/lib/index.js @@ -320,26 +320,57 @@ async function getReleasesByTag(tagUrl, params = {}, options = {}) { imageFormat: await _parseImageFormatArg(options.imageFormat, 9) }; - return getReleasesByTagFilterOptions(tagUrl) - .then( filterOptions => { - const defaultFilters = {}; - filterOptions.forEach( filter => { - let selectedOption = filter.options.find( o => o.selected ); - let defaultOption = filter.options.find( o => o.default ); - if (selectedOption) { - if (filter.name === 'tags') { - defaultFilters[filter.name] = [selectedOption.value]; - } - else { - defaultFilters[filter.name] = selectedOption.value; - } - } - else if (defaultOption) { - defaultFilters[filter.name] = defaultOption.value; - } - }); + const _getDefaultFilters = tagUrl => { + if (options.useHardcodedDefaultFilters) { + const tagUrlPath = utils.splitUrl(tagUrl).path; + if (tagUrlPath.endsWith('/')) { + tagUrlPath = tagUrlPath.substr(0, tagUrlPath.length - 1); + } + const tagValue = tagUrlPath.split('/').pop(); - const paramFilters = params.filters ? Object.assign(defaultFilters, params.filters) : defaultFilters; + return Promise.resolve({ + tags: [tagValue], + location: 0, + format: 'all', + sort: 'pop' + }); + } + else { + return getReleasesByTagFilterOptions(tagUrl) + .then( filterOptions => { + const defaultFilters = {}; + filterOptions.forEach( filter => { + let selectedOption = filter.options.find( o => o.selected ); + let defaultOption = filter.options.find( o => o.default ); + if (selectedOption) { + if (filter.name === 'tags') { + defaultFilters[filter.name] = [selectedOption.value]; + } + else { + defaultFilters[filter.name] = selectedOption.value; + } + } + else if (defaultOption) { + defaultFilters[filter.name] = defaultOption.value; + } + }); + + return defaultFilters; + }); + } + } + + return _getDefaultFilters(tagUrl) + .then( defaultFilters => { + const tagsFilter = defaultFilters.tags ? defaultFilters.tags.slice(0) : []; + if (params.filters && Array.isArray(params.filters.tags)) { + params.filters.tags.forEach( tag => { + if (!tagsFilter.includes(tag)) { + tagsFilter.push(tag); + } + }) + } + const paramFilters = params.filters ? Object.assign(defaultFilters, params.filters, {tags: tagsFilter}) : defaultFilters; return { filters: paramFilters,