How can I search for albums with generic titles using the Spotify Web API? - api

It is possible to search by name for an album in the Spotify catalog using the Spotify Web API.
However, if the album name is a common word or phrase, the search response may contain thousands of results. I can't see a way to narrow the search by artist name.
Here is an example: searching for album Country by artist Giant Panda Guerilla Dub Squad.
The API request is:
http://ws.spotify.com/search/1/album?q=country
The response is:
<?xml version="1.0" encoding="UTF-8"?>
<albums xmlns="http://www.spotify.com/ns/music/1" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/">
<opensearch:Query role="request" startPage="1" searchTerms="country" />
<opensearch:totalResults>11861</opensearch:totalResults>
<opensearch:startIndex>0</opensearch:startIndex>
<opensearch:itemsPerPage>100</opensearch:itemsPerPage>
<album href="spotify:album:1Wcnyz2zYWLIPZ1K63RXdW">
<name>How Country Feels</name>
<artist href="spotify:artist:56x8mYvS3cyDGAi8N2FxbB">
<name>Randy Houser</name>
</artist>
<id type="upc">886443789852</id>
<popularity>0.73964</popularity>
<availability>
<territories>CA US</territories>
</availability>
</album>
...more albums...
</albums>
There are 11861 results, and the results are paged, with 100 albums per page. A request can be made to get the next page, but if the album I'm looking for is on the last page I will have to make 118 separate requests to the API before I find it.
Is there a better way?

You can use the advanced search query language to help, especially if you know the artist in advance. For example:
http://ws.spotify.com/search/1/album?q=artist:Giant Panda Guerilla Dub Squad
...will limit the search to albums by that artist.
http://ws.spotify.com/search/1/album?q=artist:Giant Panda Guerilla Dub Squad Country
...will return only the album you want.
The full advanced search reference is currently unavailable in the chaos that was the new Spotify redesign, but you can find it in the Wayback machine here.

Related

extract text from documents like PAN and Aadhaar

I am using cloud google vision API to extract text from Aadhaar and PAN. How can I get exact user details like name, father's name, and address?
Raw Data
ଭାରତ ସରକାର
Government of India
ଜିତ୍ୟାନନ୍ଦ ଖେମୁକୁ
NITYANANDA KHEMUDU
ପିତା : ସୀତାରାମ ଖେମୁକୁ
Father: Sitaram Khemudu
ଜନ୍ମ ତାରିଖ / DOB : 01.07.1999
ପୁରୁଷ / Male
ମୋ ଆଧାର, ମୋ ପରିଚୟ
I have built 5-6 OCR till date like aadhar, pan, ITR, Driving Linces etc., using google cloud vision API, I think you are looking for response like
{"pan_card_no":"ECXXXXXX123",
"name":"fshksj"
}
to get such response you need to built your own logic, here are some logic's i can share with you
Perform OCR on your document using Google_cloud_vision API and store that response into one array (Goggle gives logic line by line)
Like in above case if you want to grab DOB first you can build logic like i) if "DOB" in (list of item) then grab the numeric values
To get the name what you can do is dropping the unnecessary items from list by if using if condition like (if "India" in i) or (if i.isdigit()) then drop it likewise you can drop the unnesseary items from main list to get the Name
to grab the Address what you can do is, 95% of the time address come with pincode at last, so what you can do is treat pincode as a last index of address and look of "Address" kind of keyword then add all the elements from "Add keyword index" to "pincode index" ( this can be easily done in list) to validate whether the pincode is valid or not you can use library like Pyzipin
There are multiple conditions that you can use, above are the very basic one i mentioned, if you need any specific logic then then you can ask me

Twitter Premium API Profile location operators profile_country: and profile_region: not working

I am using premium account (not sandbox) for data collection.
I want to collect:
All tweets in English that contain ‘china’ or ‘chinese’ that are user geolocated to US and not geolocated at tweet level, excluding all retweets
All tweets in English that contain ‘china’ or ‘chinese’ that are user geolocated to ‘Minnesota’ and not geolocated at tweet level, excluding all retweets
The code is as follows:
premium_search_args = load_credentials('twitter_API.yaml',
yaml_key ='search_tweets_premium_api', env_overwrite=False)
# keywords for the search
# key word 1
keywords = '(China OR Chinese) lang:en profile_country:US -place_country:US -is:retweet'
# key word 2
keywords = '(China OR Chinese) lang:en -place_country:US profile_region:"Minnesota" -is:retweet'
# define search rule
rule = gen_rule_payload(keywords,from_date='2019-12-01',
to_date='2019-12-10',results_per_call=500)
# create result stream and print before start
rs = ResultStream(rule_payload=rule, max_results=1250000,
**premium_search_args)
My problems are that:
For the first one, a large portion of the results I get didn’t satisfy the query. First, some don’t have Profile Geo enrichment, i.e. user.derived.locations attribute is not in the user object. Second, if it is, a lot don’t have country code US, i.e. they are identified to other countries.
For the second one, the result I get from this method is a smaller subset of the results I can get from 1). That is, when I filter all tweets user geolocated to Minnesota (by user.derived.locations.region) from profile_country:US, it gives a larger sample than using profile_region:“Minnesota”. A considerable amount of data is missing using this method.
I have tried several times but it seems that user geolocation operators don’t work exactly what I want. Does anyone has any idea why this is the case? I would very much appreciate any answers/suggestions/comments.
Thank you!

Google API doesn't return data for ISBN

I am using the Google API to search for books by ISBN.
I am trying with these 3 codes
0716604892, 0716604892, 0544506723
like this
https://www.googleapis.com/books/v1/volumes?q=isbn:0716604892
https://www.googleapis.com/books/v1/volumes?q=isbn:0716604892
https://www.googleapis.com/books/v1/volumes?q=isbn:0544506723
but the last one doesn't return anything when the book exists, and the ISBN code is right.
Why is that?
Use ISBN in uppercase.
type it as:
https://www.googleapis.com/books/v1/volumes?q=ISBN:0544506723
instead of:
https://www.googleapis.com/books/v1/volumes?q=isbn:0544506723

VK API - return city names in latin

I am using VK API to get list of cities in specific country. Does anyone know how to show Russian cities (which are in Cyrilic) in Latin?
Example of JSON response:
http://api.vk.com/method/places.getCities?lang=en&country_id=1&count=1000&need_all=1
I am trying to check if city exists, but if someone enter city name in latin, in some cases city check works, for example Vladivostok is Владивосток, but Moscow is Москва.
I found one solution that works for me: firstly get all cities ids by places.getCities (database.getCities) method and then use database.getCitiesById providing saved cities ids like following:
database.getCitiesById?lang=en&city_ids=1,2,123
In request to this API method you can specify needed language by parameter "lang" (e.g. lang=en) and up to 1k comma-separated cities ids (e.g. city_ids=1,2,123,...).
database.getCitiesById official documentation
As an alternative, you can get the static list of Russian cities here. This JSON array contains the slug name of each city in English. It's a free list, so anyone can edit and add correct information for any localities.

Can Redis do prefix matching?

Lets say I have a set of cities in the world like so:
EUKLOND
EUKMANC
EUKEDIN
EITROME
EITMILA
EITNAPE
EFRPARI
EFRAVIG
EFRBRES
Where the first letter is continent, next two are country and the trailing 4 are an abbreviated city name.
I would like to be able to search this set by passing in "E" which would return all the entries or EIT and retrieve all the entries for Italy or EFRPARI and get just the Paris entry.
Is this something I can do with Redis?
Generally, it's an Auto-Complete scenario.
Salvatore Sanfilippo (#Antirez), Redis's author, wrote a thorough blog post about how to accomplish this.
UPDATE: I just saw another great blog post, that first takes Salvatore's solution and explains it in a clear way, and second offers another solution that is good also for multiple-word phrases.