Musicbrainz artist image and information - web-services

I have managed to get an artist's information using the following
http://musicbrainz.org/ws/2/artist/?query=artist:michael%20jackson
Which returns the MBID (or ID). The response here returns back a lot of information but not an image of the Artist.
So further reading leads me to CoverArt (https://musicbrainz.org/doc/Cover_Art) and https://archive.org/ and to get an image its led me to this link https://musicbrainz.org/doc/Cover_Art_Archive/API, which is targeting the release and not the Artist (the way i understand it, is, the release is the artwork of an album that an artist has done, but what i require is an image of the artist itself.
I'm not sure how to obtain the artist's image or if im going the wrong way about it as I've read a lot of links but i think im missing something here and wondered if anyone could advise? As far as i know and think i need the ID of the artist to start with but using the release entity doesnt return the image of an artist and ive substituted release with artist but that returns a 404.

With that query you get the MBID. Then you can make this lookup:
http://musicbrainz.org/ws/2/artist/f27ec8db-af05-4f36-916e-3d57f91ecf5e?inc=url-rels
Note the inc=url-rels part.
More details and other possibilities are given in the MusicBrainz XML Web Service Documentation.
You can't get the urls from the search directly.

Related

how can I scrap specific words in the webnews?

I wanna scrap the name of writer.
But the structure is too different among the news websites to get that.
For instance, the name is written by classname = reporter, author or writer etc..
I think the best way to get that is searching for reporter in the boby of webpage by useing "Ctrl + f". If there is it, it maybe appear first.
and then get the word that is in front of the word reporter that I searched.
But I don't know how I can write the code by python and that it can be.
please give me the draft or link that I can refer.

How can I create a custom module to display a calculated value on an already existing page/view?

Trying get started with custom module development on Drupal 8. Don't have previous Drupal dev background. Been reading and watching some materials in the past 2 or so weeks.
I decided to dare doing a little more "complex" other than "Hello World", but I got stuck on how would I actually go about this.
This is what I have so far:
I created a content type for "people". It's very simple, all it has is the person's name and birthdate (date only), so you can use the form to input a few people.
I created a view that displays the list of people, their names and their birthdate. Of course everything so far is using the core admin thing.
Now, I wanted to create a custom module that calculates the person's age (based on the date stored in the DB). It takes today's date, subtracts the person's birthdate, and calculates their age.
Then, with some magic, it returns the age to the render/page output and now this calculated value (the age) will be displayed on the view as well along with the person's name and birthdate.
I assume I would need to "hook into" a place somewhere, where the list of people is returned from the database. Then I loop through the data, get the birthdate, calculate the age, stick the result (age) back into the data, and then the page/view will display this - somehow.
Of course I am already stuck on how would I go about doing this? Where would I need to hook into? With what API? And then of course, I created a view already, but the view doesn't have the "age" field - since that is calculated on the fly. So where and how would I display it?
So many questions...
If anyone would know some tutorial that is similar to this, I'd appreciate it. It's kinda tough getting started with the "custom" side of Drupal.
Thanks for some tips!
without custom programming
You can actually do this without custom coding. For this you can I would use either of the following modules field_token_value or computed_field.
They both create a field without giving the user a textbox to input any value.
The value of such fields are calculated from predefined rules/custom coding/tokens defined per field.
from your custom theme
The easiest way is to do this on the theming layer and not store this value in the database. You have to use hook_preprocess_node in your THEMENAME.theme
function THEMENAME_preprocess_node(&$variables){
//install debug and kint to be able to use
//kint($variables);
$node = $variables["node"];
if($node->getType() == "CONTENTTYPE" && $node->hasField('field_date')){
//get date value something like "2018-09-07T21:35:30"
$date = $node->field_date->value;
//your logic and age calculations
// ...
$age = 35;
//set variable to use in node.html.twig based templates
$variables["person_age"] = $age;
}
}
In order to get more information on what is available install debug module and enable kint (which is part of debug) to be able to see variables using kint function
Than copy node.html.twig from your custom theme (or parent theme or classy core theme) to your THEMENAME/templates folder and rename it node--CONTENTTYPE.html.twig.
In there you can include the variable you just created in proprocess.
person age: {{ person_age }}
Make sure you clear the cache for all those changes to be seen by Drupal.
FOR MORE INFO
To find out what twig templates to override see here
More on twig and getting available variables
Getting more info on which twig template is used can also be obtained by enabling debug mode on previous link.
I would suggest you pick up a book on drupal development to understand all those concepts in a more concrete way.

What is the "monetization_status" of video in Facebook api and when to use it?

What is the "monetization_status" of video in Facebook api and when to use it?
I am looking for any documentation about this field and the only page I found is this: https://developers.facebook.com/docs/graph-api/reference/video, saying that this field is the "enum" type, no possible values, nor when to use it.
The point is that I get "ineligible" for videos that I have monetized before, and I wonder what does it mean, and how can I get status "eligible"?
Thanks

Page redirected/ merged. Can this detected with GraphAPI?

This page for example:
https://www.facebook.com/202344606451254
Actually points to:
https://www.facebook.com/23766404924
Is there any way to detect this using GraphAPI?
GraphAPI queries with the old id, eg
https://graph.facebook.com/v2.3/202344606451254/feed?access_token=xxx
will return no data
In case the links change in the future: API queries of the respective IDs show the first is "wpp plc" and the second is "wpp". The title of the first link says these ids have been merged.
You might want to try this:
/v2.3/202344606451254?fields=best_page
I'm not sure exactly what circumstances will cause that to work, but I tested it a little on Graph Explorer. It seems to be a field that will be filled in if the user should be using a better page than the one they tried to access:
The page you mention in your first link returns a structure that contains information about the second link.
The page in the second link does not return any data for that field. I tested several pages I manage, and they also return no data for that field.

RESTful API and Foreign key handling for POSTs and PUTs

I'm helping develop a new API for an existing database.
I'm using Python 2.7.3, Django 1.5 and the django-rest-framework 2.2.4 with PostgreSQL 9.1
I need/want good documentation for the API, but I'm shorthanded and I hate writing/maintaining documentation (one of my many flaws).
I need to allow consumers of the API to add new "POS" (points of sale) locations. In the Postgres database, there is a foreign key from pos to pos_location_type. So, here is a simplified table structure.
pos_location_type(
id serial,
description text not null
);
pos(
id serial,
pos_name text not null,
pos_location_type_id int not null references pos_location_type(id)
);
So, to allow them to POST a new pos, they will need to give me a "pos_name" an a valid pos_location_type. So, I've been reading about this stuff all weekend. Lots of debates out there.
How is my API consumers going to know what a pos_location_type is? Or what value to pass here?
It seems like I need to tell them where to get a valid list of pos_locations. Something like:
GET /pos_location/
As a quick note, examples of pos_location_type descriptions might be: ('school', 'park', 'office').
I really like the "Browseability" of of the Django REST Framework, but, it doesn't seem to address this type of thing, and I actually had a very nice chat on IRC with Tom Christie earlier today, and he didn't really have an answer on what to do here (or maybe I never made my question clear).
I've looked at Swagger, and that's a very cool/interesting project, but take a look at their "pet" resource on their demo here. Notice it is pretty similar to what I need to do. To add a new pet, you need to pass a category, which they define as class Category(id: long, name: string). How is the consumer suppose to know what to pass here? What's a valid id? or name?
In Django rest framework, I can define/override what is returned in the OPTION call. I guess I could come up with my own little "system" here and return some information like:
pos-location-url: '/pos_location/'
in the generic form, it would be: {resource}-url: '/path/to/resource_list'
and that would sort of work for the documentation side, but I'm not sure if that's really a nice solution programmatically. What if I change the resources location. That would mean that my consumers would need to programmatically make and OPTIONS call for the resource to figure out all of the relations. Maybe not a bad thing, but feels like a little weird.
So, how do people handle this kind of thing?
Final notes: I get the fact that I don't really want a "leaking" abstaction here and have my database peaking thru the API layer, but the fact remains that there is a foreign_key constraint on this existing database and any insert that doesn't have a valid pos_location_type_id is raising an error.
Also, I'm not trying to open up the URI vs. ID debate. Whether the user has to use the pos_location_type_id int value or a URI doesn't matter for this discussion. In either case, they have no idea what to send me.
I've worked with this kind of stuff in the past. I think there is two ways of approaching this problem, the first you already said it, allow an endpoint for users of the API to know what is the id-like value of the pos_location_type. Many API's do this because a person developing from your API is gonna have to read your documentation and will know where to get the pos_location_type values from. End-users should not worry about this, because they will have an interface showing probably a dropdown list of text values.
On the other hand, the way I've also worked this, not very RESTful-like. Let's suppose you have a location in New York, and the POST could be something like:
POST /pos/new_york/
You can handle /pos/(location_name)/ by normalizing the text, then just search on the database for the value or some similarity, if place does not exist then you just create a new one. That in case users can add new places, if not, then the user would have to know what fixed places exist, which again is the first situation we are in.
that way you can avoid pos_location_type in the request data, you could programatically map it to a valid ID.