Skip to content

Commit 52ea6ce

Browse files
authored
add filters section and general formatting to README
1 parent fc06de8 commit 52ea6ce

File tree

1 file changed

+147
-16
lines changed

1 file changed

+147
-16
lines changed

README.md

Lines changed: 147 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ With support for filters like ranges of date added, release date, genres, audio
66

77
## What does it solve?
88

9-
Around 2500 Liked songs in, I needed a way to organise the chaos without having to move away from 'liking' any more songs.
10-
Hopefully, it's useful to more people out there with little time and a lot of songs :)
9+
Around 2500 Liked songs in, I needed a way to organise the chaos without having to move away from 'liking' any more songs.
10+
Hopefully, it's useful to more people out there with little time and a lot of liked songs :)
1111

12-
With heartify, you may
12+
### What you can do
1313

1414
✔️ Export them to a playlist - you can now share your liked songs!
1515

@@ -23,28 +23,35 @@ With heartify, you may
2323

2424
✔️ Filter by audio features - make a workout playlist of songs in a certain bpm range, for example
2525

26+
### No library size limits
27+
28+
There's no (known) limit to the number of songs Heartify can fetch, so bring along your massive libary of 7000 liked songs (or more?)!
29+
Just be prepared for it to take a bit longer with the measures in place to account for Spotify's rate limits.
30+
2631

2732
## Getting Started
2833

2934
### Installation
3035

31-
Heartify is currently a work in progress, but you can install it here:
36+
Heartify is currently a work in progress, but you can install it by running:
3237

3338
```sh
3439
npm install -g heartify-cli
3540
```
3641

37-
### Authorization
42+
### Authorisation
3843

39-
Run the following command from any directory, all data is stored locally where heartify is installed.
44+
Run the following command from any directory, all data is stored locally where Heartify is installed.
4045
Then follow the instructions to authorise access to your Spotify library.
4146

4247
```sh
4348
heartify init
4449

4550
```
4651

47-
This command needs to be run just once, and you're logged in until you revoke permissions from your account page, logout, or until Spotify automatically revokes permissions from time-to-time (in which case, run `heartify init` again). Heartify uses the OAuth 2.0 Authorization Code with PKCE flow, and refreshes the access token automatically until it's revoked.
52+
This command needs to be run just once, and you're logged in until you revoke permissions from your account page,
53+
logout, or until Spotify automatically revokes permissions from time-to-time (in which case, run `heartify init` again).
54+
Heartify uses the OAuth 2.0 Authorization Code with PKCE flow, and refreshes the access token automatically until it's revoked.
4855

4956
### Basic Examples
5057

@@ -62,20 +69,27 @@ This command needs to be run just once, and you're logged in until you revoke pe
6269

6370
```
6471

65-
2. Export your liked songs from a specific year (2023 in the example). You can use `--added-from` or `-f` and `--added-to` or `-t`, but there's also a convenience option `--year` or `-Y` available, used here:
72+
1. Export your liked songs from a specific year (2023 in the example). You can use `--added-from` or `-f`
73+
and `--added-to` or `-t`, but there's also a convenience option `--year` or `-Y` available, used here:
6674

6775
```sh
6876
heartify export 'Liked Songs 2023' -Y 2023
6977

7078
```
7179

72-
3. Filter by genre: There are several filters available, and one of them is `genre`. To see all the genres detected in your liked songs that you can filter by, run
80+
1. Filter by genre: There are several filters available, and one of them is `genre`.
81+
To see all the genres detected in your liked songs that you can filter by, run
7382

7483
```sh
7584
heartify show-genres
7685

7786
```
7887

88+
> Note:
89+
> As of now, you need to have run at least one `export` command before running `show-genres` as it needs to fetch the
90+
> liked songs first while exporting to identify the genres. This will be fixed in a future update.
91+
92+
7993
Then pick a genre and filter (replace '\<genre name\>'):
8094

8195
```sh
@@ -90,14 +104,16 @@ This command needs to be run just once, and you're logged in until you revoke pe
90104

91105
```
92106

93-
If genre names contain spaces or special characters, either wrap it in quotes, or wrap the entire field-value pair in quotes. For example, this command would make (a rather interesting) playlist out of songs which fall into at least one of the following genres: 'disco', 'conscious hip hop', 'k-indie', and 'escape room'
107+
If genre names contain spaces or special characters, either wrap it in quotes, or wrap the entire field-value pair in quotes.
108+
For example, this command would make (a rather interesting) playlist out of songs which fall into at least one of
109+
the following genres: 'disco', 'conscious hip hop', 'k-indie', and 'escape room'
94110

95111
```sh
96112
heartify export 'My multi-genre mix' --filter genre=disco 'genre=conscious hip hop' genre='k-indie' genre='escape room'
97113

98114
```
99115

100-
4. Filter by custom range of date added using the `--added-from` or `-f` option, the `--added-to` or `-t` option, or both
116+
1. Filter by custom range of date added using the `--added-from` or `-f` option, the `--added-to` or `-t` option, or both
101117

102118
```sh
103119
heartify export 'Liked Songs, November 2023' -f 2023-11-01 -t 2023-11-30
@@ -119,27 +135,142 @@ This command needs to be run just once, and you're logged in until you revoke pe
119135

120136
- `YYYYMMDD`: 20230101, 20230730
121137
- `YYYY-MM-DD`: 2023-01-01, 2023-07-30
122-
- `YYYY`: 2023, 2022 (NOTE: this is converted to midnight at the start of the year if it's a 'from' value, and the timestamp at the last second before midnight of January 1st if it's a 'to' value)
138+
- `YYYY`: 2023, 2022 (NOTE: this is converted to midnight at the start of the year if it's a 'from' value, and the timestamp
139+
at the last second before midnight of January 1st if it's a 'to' value)
123140

124-
5. Filter by other features of the tracks, like date released, key, or tempo (Full list at TODO)
141+
1. Filter by other features of the tracks, like date released, key, or tempo (see the list of supported features [here](#string-fields))
125142

126143
```sh
127144
heartify export 'Liked Songs, 120bpm' --filter tempo=120
128145

129146
```
130147

131-
6. Filter by ranges: DateTime filters and Number filters (TODO: link) support ranges. Ranges are written as `field=[from, to]`. Either the 'from' or the 'to' value can be omitted for a range unbounded on one side
148+
1. Filter by ranges: DateTime filters and Number filters (TODO: link) support ranges. Ranges are written as `field=[from, to]`.
149+
Either the 'from' or the 'to' value can be omitted for a range unbounded on one side
132150

133151
```sh
134152
heartify export 'Liked Songs, 100-120bpm' --filter tempo=[100,120]
135153

136154
```
137155

138-
7. Combine options and filters
156+
1. Combine options and filters
139157

140158
```sh
141159
heartify export 'Liked Songs 2023, 100-120bpm, danceable' -Y 2023 --filter tempo=[100,120] danceability=[0.7,]
142160

143161
```
144162

145-
## TODO: Detailed Docs
163+
164+
## Detailed Docs (TODO)
165+
166+
### `--filter`
167+
168+
Filters are of the form `field=value` and accept any field from the list of supported fields below.
169+
170+
The value can be either individual values like in `genre=disco` and `time_signature=4`, or ranges like
171+
in `tempo=[100,120]` (only DateTime and Number fields accept ranges at the time of writing)
172+
173+
Ranges must have at least the start or the end specified. The search includes the end points.
174+
175+
```sh
176+
# songs with tempo from 100 BPM to 120 BPM (both inclusive)
177+
--filter tempo=[100,120]
178+
179+
# songs with tempo >= 100 BPM
180+
--filter tempo=[100,]
181+
182+
# songs with tempo <= 120 BPM
183+
--filter tempo=[,120]
184+
185+
```
186+
187+
If multiple filters are given for the same field, they are joined by OR in the search
188+
189+
```sh
190+
# songs in the genres 'pop' or 'rock'
191+
--filter genre=pop genre=rock
192+
193+
# songs released in the 60's or in the 80's
194+
--filter release_date=[1960-01-01,1969-12-31] release_date=[1980-01-01,1989-12-31]
195+
196+
```
197+
198+
Filters for different fields are joined by AND
199+
200+
```sh
201+
# songs in the genre 'pop' released in the year 1990
202+
--filter genre=pop release_date=[1990-01-01,1990-12-31]
203+
204+
# songs by BTS released since 2020
205+
--filter artist=BTS release_date=[2020-01-01,]
206+
207+
# the above search can also be written like this as 'from 2020' is parsed as 'from midnight of 2020-01-01'
208+
--filter artist=BTS release_date=[2020,]
209+
210+
```
211+
212+
Filters do not need to be wrapped in quotes as long as they do not contain ANY spaces.
213+
Wrap them in single/double quotes when they contain whitespace.
214+
215+
```sh
216+
# without spaces
217+
--filter artist=BTS genre=k-pop release_date=[2016-01-01,2018-12-31]
218+
219+
# quotes can be around the whole field-value pair or just the string that has spaces
220+
--filter artist='J. Cole' 'artist = BTS' 'artist = Epik High'
221+
222+
# quotes are needed if you prefer writing ranges with a space before/after the comma or the brackets
223+
# the following filters are valid and return the same result:
224+
--filter 'tempo=[60, 80]'
225+
--filter tempo='[60, 80]'
226+
--filter tempo=[60,' 80']
227+
--filter tempo=[60, '80']
228+
--filter tempo=['60', '80']
229+
--filter 'tempo = [ 60, 80 ]'
230+
231+
```
232+
233+
### String fields
234+
235+
- `artist`
236+
- `genre`
237+
238+
String fields accept only individual values (and not ranges).
239+
240+
For example, `--filter 'artist=[BTS,Epik High]'` would mean artists 'from BTS to Epik High' and is not a supported search
241+
242+
### DateTime fields
243+
244+
- `release_date`
245+
246+
### Number fields
247+
248+
These fields correspond to those returned by the Spotify Web API. The descriptions here are excerpts of the full descriptions,
249+
which can be found in the [Spotify Web Api docs for Audio Features](https://developer.spotify.com/documentation/web-api/reference/get-audio-features).
250+
251+
| field | description | range |
252+
|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------|
253+
| `danceability` | How suitable a track is for dancing based on <br>a combination of musical elements including tempo, <br>rhythm stability, beat strength,and overall regularity | 0.0 to 1.0<br>(float) |
254+
| `energy` | Represents a perceptual measure of intensity <br>and activity | 0.0 to 1.0<br>(float) |
255+
| `key` | The key the track is in. <br>Integers map to pitches using standard Pitch Class <br>notation. E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on. <br>If no key was detected, the value is -1. | -1 to 11<br>(integer) |
256+
| `loudness` | The overall loudness of a track in decibels (dB).<br>Loudness values are averaged across the entire track and <br>are useful for comparing relative loudness of tracks | -60 to 0<br>(float) |
257+
| `mode` | Mode indicates the modality (major or minor) of a track.<br>Major is represented by 1 and minor is 0. | 1 or 0<br>(integer) |
258+
| `speechiness` | Detects the presence of spoken words in a track | 0.0 to 1.0<br>(float) |
259+
| `acousticness` | A confidence measure from 0.0 to 1.0 of whether the<br>track is acoustic | 0.0 to 1.0<br>(float) |
260+
| `instrumentalness` | Predicts whether a track contains no vocals | 0.0 to 1.0<br>(float) |
261+
| `liveness` | Detects the presence of an audience in the recording.<br>A value above 0.8 provides strong likelihood that the track<br>is live. | 0.0 to 1.0<br>(float) |
262+
| `valence` | Tracks with high valence sound more positive<br>(e.g. happy, cheerful, euphoric), while tracks with <br>low valence sound more negative (e.g. sad, depressed, angry) | 0.0 to 1.0<br>(float) |
263+
| `tempo` | The overall estimated tempo of a track in beats per minute (BPM) | -<br>(float) |
264+
| `duration_ms` | The duration of the track in milliseconds | -<br>(integer) |
265+
| `time_signature` | An estimated time signature. The time signature (meter) <br>is a notational convention to specify how many beats<br>are in each bar (or measure). The time signature ranges <br>from 3 to 7 indicating time signatures of "3/4", to "7/4". | 3 to 7<br>(integer) |
266+
267+
</br>
268+
269+
---
270+
271+
## Feedback, suggestions, and bug reports welcome! 👐
272+
273+
This is a small project I've been making on the side as I'm learning JS.
274+
Feel free to open an issue for a new feature you'd like to have, suggestions, bug reports, or anything else.
275+
276+
💜

0 commit comments

Comments
 (0)