Jump to content

[Fixed] Search iTunes Store w/ feedback


Recommended Posts

Updated to include caching of HTTP requests, to somewhat more reliably return only music tracks, to return 15 results instead of 10, and to fix a silly mistake with the cache folder. This version also adds an app-store search.

 

This is probably going to be the last update before it's rewritten to use the module I'm working on, but please let me know if anything breaks in the meantime.

Link to comment
Excellent. I didn't manage to bundle requests_cache either. I need to update my workflow with a few requested features and implement some sort of cache, not only for images but for all other results. As is, it's woefully slow.

 

Yeah, the iTunes API seems a little sluggish. I found that just caching images was enough, but that doesn't do a lick of good with new searches. As for bundling requests_cache, if you have both "requests" and "requests_cache" in your workflow's folder, you can alter `requests_cache/core.py` so that its imports look like this:

import os
import sys

superpath = os.path.realpath("../")
if superpath not in sys.path:
    sys.path.insert(0, superpath)

from requests import Request
try:
    from requests.hooks import dispatch_hook
except ImportError:
    dispatch_hook = None

 

That'll cause it to find the requests module and patch it appropriately, at least as far as I can tell from eyeballing the speed pre- and post-change. When downloading a bundleable requests, be sure to check their git repository for a version tagged 0.14.2; 1.x.x won't work with requests_cache.

Link to comment
Yeah, the iTunes API seems a little sluggish. I found that just caching images was enough, but that doesn't do a lick of good with new searches. As for bundling requests_cache, if you have both "requests" and "requests_cache" in your workflow's folder, you can alter `requests_cache/core.py` so that its imports look like this:
import os
import sys

superpath = os.path.realpath("../")
if superpath not in sys.path:
    sys.path.insert(0, superpath)

from requests import Request
try:
    from requests.hooks import dispatch_hook
except ImportError:
    dispatch_hook = None

 

That'll cause it to find the requests module and patch it appropriately, at least as far as I can tell from eyeballing the speed pre- and post-change. When downloading a bundleable requests, be sure to check their git repository for a version tagged 0.14.2; 1.x.x won't work with requests_cache.

 

Sweet!! Thanks for the tip. I'll try and work that into the next version of App Store Linker this weekend.

Link to comment
Love it!  Any way to put specific triggers that load apps instead of music?

 

Try this version.

 

It's basically not that different from Pedro's workflow, it just doesn't attach an affiliate link. Haven't yet figured out how to generate a link directly to the store, so it just bounces you to the App Store webpage for the app.

Link to comment

Try this version: http://d.pr/f/lhYg

 

It's basically not that different from Pedro's workflow, it just doesn't attach an affiliate link. Haven't yet figured out how to generate a link directly to the store, so it just bounces you to the App Store webpage for the app.

 

That's a nice workflow because it includes a link to both the Mac App Store and iTunes which is a good consolidation.  However, I'm interested in searching iTunes App Store for iOS Apps.  For example, the query "its Carcassonne" yields the useless music below instead of my favorite iOS app.

 

screenshot-1359262012.jpg

 
Link to comment

That's a nice workflow because it includes a link to both the Mac App Store and iTunes which is a good consolidation.  However, I'm interested in searching iTunes App Store for iOS Apps.  For example, the query "its Carcassonne" yields the useless music below instead of my favorite iOS app.

 

 

I'll change the next version so that the "app" query searches iOS apps as well as Mac software.

 

 

Could you add a delay before it starts searching the iTunes store?  

When I search for James Horner it will feedback results for Ja, after a few seconds I get results for James and after a few more seconds I get the results for James Horner. 

 

Cheers :)

 

I haven't come up with a way to do this that I especially like. The script is executed over and over again as the user types, so adding a fixed delay would just reproduce the problem you're seeing with the scripted delay added to the delay that's already endemic to the search. David suggested not executing a search until after a few letters are typed, which is what I'll try next, but you'll still see the same problem: if you want abcdefgh, it'll search for abc, abcde, abcdefgh. Meaning it eliminates maybe one useless search from the sequence.

Link to comment

Well, in spite of my skepticism, David was naturally correct: waiting until a few characters have been typed seems to greatly improve the perceived speed of the search. Let me know if it looks that way on your end. I've also changed the "app" query so that it searches for both iOS and Mac apps, and reworked the code to take advantage of PyAl. You can download it at the original link above.

 

Edit: Further updated to reflect some changes in PyAl, it now appears to be just blazingly fast on my end. Hope you're all noticing similar improvements.

 

Edit Edit: However, the bundled libraries have made it too large for AlfPT, so keep an eye on this thread for further updates.

Link to comment
Well, in spite of my skepticism, David was naturally correct: waiting until a few characters have been typed seems to greatly improve the perceived speed of the search. Let me know if it looks that way on your end. I've also changed the "app" query so that it searches for both iOS and Mac apps, and reworked the code to take advantage of PyAl. You can download it at the original link above or here: http://d.pr/f/XEwn

 

Edit: Further updated to reflect some changes in PyAl, it now appears to be just blazingly fast on my end. Hope you're all noticing similar improvements.

 

Edit Edit: However, the bundled libraries have made it too large for AlfPT, so keep an eye on this thread for further updates.

 

I'm not getting any results after installing this update. It keeps 'Searching...' 

Link to comment
I'm not getting any results after installing this update. It keeps 'Searching...' 

 

It's working fine for me. What are you searching for? If it's under three characters the search won't be executed anymore. If that's not the problem, please change the command in the workflow to "python its.py '{query}' 2>&1 | tee output.log" and post what output.log shows.

Link to comment
It's working fine for me. What are you searching for? If it's under three characters the search won't be executed anymore. If that's not the problem, please change the command in the workflow to "python its.py '{query}' 2>&1 | tee output.log" and post what output.log shows.

 

Here is the log:

 

 

Traceback (most recent call last):
  File "its.py", line 3, in <module>
    import PyAl
  File "/Users/christophe/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.EA4B5E15-822A-41B9-A595-FE41EAAB4526/PyAl/__init__.py", line 1, in <module>
    from .core import *
  File "/Users/christophe/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.EA4B5E15-822A-41B9-A595-FE41EAAB4526/PyAl/core.py", line 9, in <module>
    import requests_cache
  File "/Users/christophe/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.EA4B5E15-822A-41B9-A595-FE41EAAB4526/PyAl/requests_cache/__init__.py", line 28, in <module>
    from .core import(
  File "/Users/christophe/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.EA4B5E15-822A-41B9-A595-FE41EAAB4526/PyAl/requests_cache/core.py", line 18, in <module>
    from requests import Request
ImportError: No module named requests

 

:)

Link to comment
I'm not getting any results in your amazon and kindle workflows. Might be a similar issue. 

 

Cheers :)

 

Thanks for the heads-up. I'm actually somewhat excited to be able to blame Amazon for this one: they've placed a redirect between my script and the results page I was trying to parse. I'm going to break for lunch and rewrite later this afternoon.

Link to comment
  • 2 months later...

I've updated this workflow so that it now searches in three ways: the Mac App Store with the keyword "app," the iTunes Music Store with the keyword "its," and the iTunes Store's iThing apps with "iph." Previously, results from iThings were crowding out Mac App Store results. It also now supports Alleyoop and alp.

Link to comment

We are a member/user of the iTunes affiliate program. It would be awesome if we would be able to parse the found url as ready-made affiliate URL's. Ours is trough Tradedoubler (iTunes Affiiate Europe), but I know US uses Linksynergy.

 

iTunes Affiliate Resources

 

Our (European) iTunes affiliate URLs look like this: 

https://itunes.apple.com/nl/app/iculture/id504842981?mt=8&partnerID=2003&tduid=NL1380330

 

This part is the affiliate part. 

&partnerID=2003&tduid=NL1380330

 

I've already changed the iph.py and app.py myself (wasn't able to change the its.py), but since the workflow is now Alleyoop compatible it would be awesome if I don't have to think about this to change this every time.

 

Thanks for the excellent workflow!

Link to comment

We are a member/user of the iTunes affiliate program. It would be awesome if we would be able to parse the found url as ready-made affiliate URL's. Ours is trough Tradedoubler (iTunes Affiiate Europe), but I know US uses Linksynergy.

 

iTunes Affiliate Resources

 

Our (European) iTunes affiliate URLs look like this: 

https://itunes.apple.com/nl/app/iculture/id504842981?mt=8&partnerID=2003&tduid=NL1380330

 

This part is the affiliate part. 

&partnerID=2003&tduid=NL1380330

 

I've already changed the iph.py and app.py myself (wasn't able to change the its.py), but since the workflow is now Alleyoop compatible it would be awesome if I don't have to think about this to change this every time.

 

Thanks for the excellent workflow!

 

 

We are a member/user of the iTunes affiliate program. It would be awesome if we would be able to parse the found url as ready-made affiliate URL's. Ours is trough Tradedoubler (iTunes Affiiate Europe), but I know US uses Linksynergy.

 

iTunes Affiliate Resources

 

Our (European) iTunes affiliate URLs look like this: 

https://itunes.apple.com/nl/app/iculture/id504842981?mt=8&partnerID=2003&tduid=NL1380330

 

This part is the affiliate part. 

&partnerID=2003&tduid=NL1380330

 

I've already changed the iph.py and app.py myself (wasn't able to change the its.py), but since the workflow is now Alleyoop compatible it would be awesome if I don't have to think about this to change this every time.

 

Thanks for the excellent workflow!

Sure. But because I see this as sort of a fringe case and because I don't want to muddy the workflow with a user-visible settings interface, the setup is going to be a little complex. You'll have to run a search once to create the file ~/Library/Application Support/Alfred 2/Workflow Data/com.danielsh.alfred.its/settings.json. That file should contain an empty JSON object. You just need to add the key--value pair "affiliate_string": "&partnerID=2003&tduid=NL1380330" and your affiliate information will be added to the links that the workflow generates. Other users can of course do this as well, with their own affiliate strings.

Edited by phyllisstein
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...