-
Notifications
You must be signed in to change notification settings - Fork 90
[WIP] Adds MusicBrainz IDs optionally #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh-pages
Are you sure you want to change the base?
Changes from all commits
22ffc45
4642b89
fa1e666
552f7b2
4d87805
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -86,6 +86,14 @@ <h4 class="modal-title">Extra Settings</h4> | |||||||||||
| <input type="text" class="form-control input-md" id="request-delay" placeholder="0" rv-value="request_delay"> | ||||||||||||
| <p class="help-block">(milliseconds, default 0) how long to wait between making requests</p> | ||||||||||||
| </div> | ||||||||||||
| <div class="form-group form-inline"> | ||||||||||||
| <input type="checkbox" class="form-control" name="lastfm-include-headers" id="lastfm-include-headers" checked="false"> | ||||||||||||
| <label for="lastfm-include-headers">Include column headers</label> | ||||||||||||
| </div> | ||||||||||||
| <div class="form-group form-inline"> | ||||||||||||
| <input type="checkbox" class="form-control" name="lastfm-include-mbid" id="lastfm-include-mbid" checked="false"> | ||||||||||||
| <label for="lastfm-include-mbid">Include MusicBrainz ID</label> | ||||||||||||
| </div> | ||||||||||||
| </div> | ||||||||||||
| </div> | ||||||||||||
| </div> | ||||||||||||
|
|
@@ -176,18 +184,33 @@ <h4 class="modal-title">Extra Settings</h4> | |||||||||||
| } | ||||||||||||
| }) | ||||||||||||
|
|
||||||||||||
| var headers = ['artist', 'album', 'name', 'date']; | ||||||||||||
| var includeMBID = $('#lastfm-include-mbid').prop('checked'); | ||||||||||||
| var includeHeaders = $('#lastfm-include-headers').prop('checked'); | ||||||||||||
|
|
||||||||||||
| if(includeMBID) { | ||||||||||||
| headers.push('mbid', 'artist_mbid', 'album_mbid'); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| async.eachSeries(requests, function(item, callback){ | ||||||||||||
| if(state.cancelled) return callback(false); | ||||||||||||
|
|
||||||||||||
| state.status = "fetching page " + (item.i) + "/" + page_count; | ||||||||||||
| lastFM(item.data) | ||||||||||||
| .then(extractTracks) | ||||||||||||
| .then(function(tracks){ | ||||||||||||
| var r = tracks.map(function(d){ | ||||||||||||
| if(includeMBID) { | ||||||||||||
| return row(headers, d) | ||||||||||||
| } | ||||||||||||
| return row(headers, d) | ||||||||||||
|
Comment on lines
+203
to
+206
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The if statement doesn't seem necessary here now that
Suggested change
|
||||||||||||
| }) | ||||||||||||
| .map(csv).join('\n') + '\n'; | ||||||||||||
|
|
||||||||||||
| var blb = new Blob([ | ||||||||||||
| tracks.map(function(d){ | ||||||||||||
| return row(['artist', 'album', 'name', 'date'], d) | ||||||||||||
| }) | ||||||||||||
| .map(csv).join('\n') + '\n']); | ||||||||||||
| includeHeaders ? (headers.join(',') + '\n' + r) : r | ||||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 will this add the headers for every page of the output? It might be easier to add the headers at the download handler instead: Line 144 in 4d87805
⬆️ , could be something along the lines of ⬇️ const header = includeHeaders ? [headers.join(',') + '\n'] : [];
var b = new Blob(header.concat(data), {type: 'text/csv'})(though maybe there's a neater way to do it…) |
||||||||||||
| ]); | ||||||||||||
|
|
||||||||||||
| data[item.i] = blb; | ||||||||||||
| bytes+= blb.size; | ||||||||||||
| state.kb = Math.round(bytes/1024); | ||||||||||||
|
|
||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,14 @@ function extractTracks(doc){ | |
| for (var i = track.childNodes.length - 1; i >= 0; i--) { | ||
| child = track.childNodes[i]; | ||
| obj[child.tagName] = child.textContent; | ||
|
|
||
| if (child.tagName) { | ||
| var mbid = child.getAttribute('mbid'); | ||
|
|
||
| if (mbid) { | ||
| obj[`${child.tagName}_mbid`] = mbid; | ||
| } | ||
| } | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😎 cool! |
||
| }; | ||
| arr.push(obj) | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(just a suggestion, feel free to ignore)
It may be possible to use Rivets rv-checked, to automatically bind this value.
Then in the code later you could access this value through the state:
……… However, I've no idea what version of Rivets this is using, and if there are any issues with the different options, so feel free to ignore this and I could take a look later.