Jump to content

vdesabou

Member
  • Posts

    466
  • Joined

  • Last visited

  • Days Won

    22

Everything posted by vdesabou

  1. wow, I really need to reproduce using your json file...Can you post a link to you (zipped) json file here? No idea, this is a question for the staff
  2. Hi, For my Spotify Mini Player workflow, I need to parse a library.json file which contains all spottily playlists of the user. The json data looks like: [ { "data" : { "discNumber" : 1, "album" : { "artist" : { "portrait" : "", "type" : "artist", "name" : "J-Boogie's Dubtronic Science", "uri" : "spotify:artist:76MRWSA9TZZg6s3Ijy7mxW" }, "availableForPlayback" : true, "availability" : 0, "cover" : "spotify:image:b9346fb9030ede38617e42eafd553d17fa7cf307", "year" : 2009, "type" : "album", "numTracks" : 0, "name" : "Soul Vibrations Dub Remixes", "uri" : "spotify:album:1QMgSZ88TOWU6ctJRAW4T6" }, "trackNumber" : 12, "availableForPlayback" : true, "uri" : "spotify:track:7AAR8NjH6RY4Dk5Ny5xQcb", "starred" : false, "artists" : [ { "portrait" : "", "type" : "artist", "name" : "J-Boogie's Dubtronic Science", "uri" : "spotify:artist:76MRWSA9TZZg6s3Ijy7mxW" } ], "popularity" : 23, "type" : "track", "isAd" : false, "availability" : 0, "isLocal" : false, "isPlaceholder" : false, "isExplicit" : false, "duration" : 290000, "isInvalid" : false, "isLoaded" : true, "name" : "1.4.u Dub - Feat. Ohmega Watts & Ragen Fykes" } } ] I am new to php (this is the first time i use it), so to parse this json file, I "loop" on all items and use strpos() to find matches: $json = file_get_contents($w->data() . "/library.json"); $json = json_decode($json,true); foreach ($json as $item) { if (strpos(strtolower($item['data']['album']['artist']['name']),strtolower($query)) !== false || strpos(strtolower($item['data']['album']['name']),strtolower($query)) !== false || strpos(strtolower($item['data']['name']),strtolower($query)) !== false) { // do something } }; This is working fine and I don't have any performances issues(i was surprised by the speed actually) with my Spotify library (2.2Mb JSON file with around 2200 tracks) But some users have more than 100 playlists, so the json file is about 15Mb To decode the json file, I had to add: ini_set('memory_limit', '128M' ); Questions: Is it a problem to set memory_limit like this? Is there a clever way to read/parse a JSON file? What about transforming the json data into a SQL db? Would it give better performances? I'm open to any suggestions :-) Cheers
  3. Download Version 1.11 History 1.11: Updated allocated memory to 128M.
  4. Any chance you can share with me your library.json file? I would like to avoid subscribing to 100+ playlists, just to reproduce your problem :-) I tried to send you a private message but apparently you can't receive it.. Please send me a direct message with a link to your json file.
  5. Yes it produces it itself if it cannot find it. This is where is it failing. Let me have a deeper look, I'll have to reproduce the problem first
  6. Thanks. Can you try version 1.10, that should hopefully fix the issue
  7. Can you check that you're using the latest version (1.9) because since version 1.7, you should have library_starred_playlist.json Please give me the output.log also
  8. Mine is "only" 2.1Mb That's weird because if you use "starred playlist search scope only", the json file used is "library_starred_playlist.json", can you check that you have one in same directory? If you can zip and provide me the 2 json files, I would be able to investigate more Also, can you edit the spot_mini script filter and change it to: php -f main.php -- "{query}" 2>&1 | tee output.log And then provide the output.log that will be generated in the workflow directory
  9. check "running-apps" workflow here: http://tedwise.com/2013/03/04/alfred-2-workflows/
  10. Unfortunately, I don't think there is a way to automate it as, if I'm not wrong, the Spotify App API (http://developer.spotify.com/technologies/apps/docs) does not provide a way to do that... If you're using 100+ playlists, your library.json will be very huge. I suggest that you only use "starred playlist search scope only", otherwise you might hit perf issues. Please let me know your feedback once you're using it Thanks!
  11. Download Version 1.9 History 1.9: Do not fetch online artworks for current track(for performance reasons). Minor bug fixes. New icons.
  12. Yeah no worries, I forgot I added that on my side :-) Cheers
  13. Ok I see, it's more an overall problem... My library.json file is "only" 2.2Mb, and that remains fluid (see the video demo I posted to compare to yours). I personally prefer to have something really responsive for the tracks I listen the most (my starred playlist). When I want to listen for one of my playlists, I can search for it because i created the playlists.json file, and start the playlist quickly. So I was thinking to get from the library.json a subset in a library_starred_playlist.json which contains only starred playlist. This is technically possible to do that. Would that help in your case?
  14. Can you try with latest version: 1.8: Fix problem introduced in version 1.7 with files names with spaces
  15. Thanks. Actually that's what I did at the beginning (having a separate keyword spot_mini to update the library.json file), but then I figured out that most of people will call the mini player by using an hotkey so they will be unaware of this way to update. So I preferred to put everything in the Settings. Maybe I'm missing something, but I don't get how it is easier like this? In any case thanks for your contribution, and I hope you like this workflow Cheers
  16. That's why, it uses word and does a "save as"
  17. Can you tells me more: file names, screenshots, Microsoft version, osx version, Lang used, etc...
  18. That's probably because of the spaces in the file name. I'll try to fix it asap.
  19. Thanks. I wanted to use your workflow to get the path of the Data directory, (as the data() method in http://dferg.us/workflows-class/ php) I ended up doing: oldIFS="$IFS" IFS=$'\n' NVPREFS="${HOME}/Library/Application Support/Alfred 2/Workflow Data/" BUNDLEID=$(/usr/libexec/PlistBuddy -c "Print :bundleid" "info.plist") cp ${NVPREFS}${BUNDLEID}/myfile.txt ${NVPREFS}${BUNDLEID}/myfile.txt.bak #rm library.json.bak IFS="$oldIFS" It would be nice to have such kind of method in you workflow handler :-)
  20. I believe this post will help you to do what you want http://www.alfredforum.com/topic/1920-bash-workflow-handler/ See also my last post here http://www.alfredforum.com/topic/1920-bash-workflow-handler/?p=10348
  21. 1.7: Fixed a bug where image was not displayed in the sharing window
  22. Cool, I'll definitely use it in the future! Would it be possible to add the 'autocomplete' in addResult() ?
×
×
  • Create New...