How to get work data by recording ID using MusicBrainz Json API? - musicbrainz

Many tracks in my library have no language information. It appears that MusicBrainz does not provide language information for a recording, only for a work.
How can I get a work ID if I know recording ID?

You can link a work to a recording through a performance.
Forward link phrase: {live} {medley:medley including a} {partial} {instrumental} {cover} recording of
Reverse link phrase: {live} {medley:medleys including} {partial} {instrumental} {cover} recordings
Long link phrase: is a {live} {medley:medley including a} {partial} {instrumental} {cover} recording of
Description: This is used to link works to their recordings.
entity0 cardinality: Few relationships (0)
entity1 cardinality: Many relationships (1)
UUID: a3005666-a872-32c3-ad06-98af558e99b0
Performances are explained in more detail in the documentation.
Here's an example of the relationship:
A Day in the Life (original stereo studio mix) by The Beatles is a recording of A Day in the Life
A Day in the Life by Affinity is a live instrumental cover recording of A Day in the Life
edit:
As you have commented, you need the relationship in the opposite direction, and this call does the trick:
http://musicbrainz.org/ws/2/recording/fcbcdc39-8851-4efc-a02a-ab0e13be224f?inc=‌​work-rels&fmt=json

Related

YouTube API V3 - How to get ALL game live streams

I'm trying to get "ALL" game live streams from youtube using API.
The way I first used is through "Search.list" with parameters: https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.search.list?part=snippet&eventType=live&maxResults=50&type=video&videoCategoryId=20. But in this way when I try to iterate results using PageToken, I can only get around 100 results while in the API response I can see "totalResults" is around 2000. Then I came into this topic and realized that "Search.list" is actually kind of "ranking" algorithm instead of "fetch all data from DB", which means "totalResults" is just an estimated number of results.
Then I came to use "liveBroadcasts.list" but it returns no results: https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.liveBroadcasts.list?part=id&broadcastStatus=active&maxResults=50&_h=8&
And for other APIs, they either need channelId or other ids.
Is there any way to get all game live streams regardless of any ids?
According to Youtube Category ID list, Gaming resides on number 20 category. In case you want to try a different category in the future, instead of videoCategoryId=20, you can try videoCategoryId=31 - that's for Anime/Animation.
Try to run this on your browser to get all live streams:
https://www.googleapis.com/youtube/v3/search?part=snippet&eventType=live&type=video&videoCategoryId=20&regionCode=US&maxResults=50&key=SERVER_API_KEY_HERE

Youtube API V3: Total comments count [Videos]

I want to get all video comments of a channel. At the moment I'm proceeding like this:
1.) Getting all video ids of a channel (1 quota)
2.) Sending new request with "part: statistics" and getting the total comment count to a youtube video (2 Quota)
It's polling in 30 seconds intervall and I wanted to reduce the quota. Therefore is there a possibility to query whether there are any new comments for a channel videos (Total amount of comments for a channel including channel comments would be fine too)? Like saving the old value of total amount of comments and comparing it with the new amount of the query?
No, from my experience.
I would not use video's commentCount.
- you can pull over 260 comments from a video whose comment count is only 243. https://www.youtube.com/watch?v=87xYGDR_eME
I would not try optimizing by stopping at recent comments.
- this would work for threads, but each thread has replies. So you have to check each thread anyways just to see if they have new replies.
- note: it's dangerous to use commentThreads' reply mode, as it may only return a subset of replies. Instead get a comment list using parentId.
Perhaps, if you sort by time and save the id of comments you've collected, you can use cheap requests like id to figure out which comments are new and pull them with snippet.
- stop when you get to an id you've already gathered.
This may not be simple though because publishedAt or updatedAt leave two questions:
will an old comment be bumped to the top if it's edited? If so, you can't stop once you recognize a comment id, because it might have jumped ahead of new comments (unless the change the id when it's edited).
will the old comment not be bumped if edited? If this is the case, you need to check snippet for each comment as the textDisplay may be different. In this case I can see no optimizations.

Youtube data API, query within channel lead to unexcpected results

I'm trying to use Youtube Data API for a project, the goal is seeking for a keyword in a channel and show the response to the user. I used the Search for "snippet" part and launched it querying for a specific keyword and specifing the channel id but the response didn't include all the videos that I was expecting. For instance, let's say that the channel has 10 videos with "c" charachter in the title, setting the q field with "c" value will return only one video.
On the other side, if I search for a whole word it returns some videos with that word on title and some other videos that doesn't have it, neither in description. The order criteria in this case seems to be ok (from the strongest match to the most weak), but I don't know if all of this is working fine.
Is this a normal behaviour or am I doing something wrong?
Setting an order on the search, the issue seems to be solved.

Getting a sum from Parse with Parse Cloud Code (for iOS app)

I'm new to Parse Cloud Code and am struggling with a seemingly simple task.
I'm working on a small iOS game where the users can choose from a list of characters to play -- imagine mario or luigi. In addition to tracking user scores in the game, I'm tracking total points for each character in Parse, so I can display a "mario" total and a "luigi" total (from all users.)
There could be multiple users playing at once (I hope), so I don't have Parse saving to just one mario and one luigi counter. Instead, each user gets a running count of their own mario and luigi scores.
So how do I pull the total marioPoints and total luigiPoints?
Parse doesn't have SQL-styled querying, so I've been looking at Parse Cloud Code and their "average stars" example (https://parse.com/docs/cloudcode/guide#cloud-code) looked kind of close at first glance:
But I can't get it sorted. And even if I could, it's limited to 1,000 responses, which wouldn't be enough. (I'm optimistic.)
Thanks!
Your best option is to keep a running total when any individual user update is saved. Do that using a save hook and the increment( attr, amount ) function.

How does YouTube calculate the number of views for a video?

I have made an internal movie site in .Net.
I play the movie trailers using jw player. Now I want to know how to calculate the number of views for a video?
Is it possible through code?
PLease help.
NBL I dont have any database. I add the videos through an xml and the code reads the xml.
A simple approach is to tally the number of pageloads for the page that contains the video, rather than the number of times the video itself is played. First, create a table in your database that contains these fields:
DateTime date // date of pageloads -- we'll get to this in a minute
int videoID // Unique Identifier for the video loaded
int count // Number of pageloads
When I tally pageloads, I do them by day so I can compile statistics over time. Of course, you can use a different granularity depending on your particular needs.
Additionally, I don't particularly like writing to the database with each pageload, so I have a class I've written that caches the hits, then writes them after every hundred hits or so.
In this class, I also retain each user's IP address. This allows me to ferret out duplicate pageloads. A subsequent task, which I'm working through in my own hitcounter, is to triage humans, legitimate spiders and unwelcome bots.
Not sure exactly what you need.. but you can handle the play command (button or loading... however your videos are played), and attach that to a counter that you save in your database.
We would need a lot more (code set, video codec and such) before giving more.
You can also create a separate table with these columns :
VideoId
IP adress
And add a row each times an user watch a video...
Then you will calculate unique watch and not duplicate
(Instead of ip adress you can store userId if your users are registered)
The database would have a table for videos, including a Hits column.
When you request the page from the server, the server would execute a stored procedure that adds +1 to the 'Hits' column.
If you are embedding videos on your page, it's worth being aware of YouTube's policy on the question of autoplaying those videos, in relation to the official viewcount. If in the player you set autoplay = true, or equivalent, then the YouTube view count doesn't increase. This is to counter spammy viewcount auto-augmentation pages. The user has to click on the play button, and watch all, or at least most, of the video to count as a view.

Resources