Closed Sandlayth closed 9 years ago
It is related to this issue with pafy, which is used by mps-youtube to get the search results, and it is due to an API change by YouTube. https://github.com/np1/pafy/issues/78 Also: https://github.com/np1/mps-youtube/issues/249
Oh, this is a sad day. So, guess I am going back to watching youtube on youtube.com with double the cpu workload again. My battery life will be crippled.
I think I mispoke. This result is the uniq one, regardless of the query
This is due to the API being deprecated :(
I have created a branch with a very incomplete search functionality based on gdata 3: https://github.com/ids1024/mps-youtube/tree/gdata3wip
Currently it only can display page one of results and all videos appear to have a length of 20 sec. It is probably a bad idea to try to add a video to a playlist on this branch, because it will save the wrong metadata. Caveat emptor.
Nice work, @ids1024. I know it's not grabbing all the data yet but it's neat how few changes to the existing codebase were required to get it to show a page of results. It seems pretty snappy too.
It unfortunately looks like you can't request the "contentDetails" part along with a search request, so there's no way to get information about the duration etc without at least one additional HTTP requests. Maybe YouTube could add this.
I believe I'm correct in stating you can only get the following info for each video via the search endpoint, which doesn't seem like too much:
{
"snippet":{
"publishedAt":"2014-02-12T21:01:24.000Z",
"channelId":"UCJ6td3C9QlPO9O_J5dF4ZzA",
"title":"[Happy Hardcore] - nanobii - Rainbow Road [Monstercat Release]",
"description":"Support on Beatport: http://monster.cat/1gqSVQY Support on Bandcamp: http://monster.cat/1eUyTym Support on iTunes: http://monster.cat/1g2TwX9 --- Listen on ...",
"thumbnails":{
"default":{
"url":"https://i.ytimg.com/vi/a0Aauep0VWs/default.jpg"
},
"medium":{
"url":"https://i.ytimg.com/vi/a0Aauep0VWs/mqdefault.jpg"
},
"high":{
"url":"https://i.ytimg.com/vi/a0Aauep0VWs/hqdefault.jpg"
}
},
"channelTitle":"MonstercatMedia",
"liveBroadcastContent":"none"
}
}
Having a look at the quota, using the same key for the whole application would allow approximately 1500 daily users who perform an average of 50 searches and look through a couple of pages of data (using 100 + 5 per video units per page of results, 100 for search + 5 for each video for which duration/extra data is retrieved with an assumption of 30 videos per page and each user flicking through 5 pages or so of data).
Having missed the previous update by @ids1024, I also made some changes to get at least the standard search to work with the new API. Just like the solution by @ids1024 , it is currently limited to the first page of search results, but since I am in fact making the additional HTTP request @lol768 was concerned with, track durations are obtained correctly.
Edit: sorry, forgot to link the commit: JKatzwinkel/mps-youtube@42bc06374488c645f7ca23e6757f73eb33a965f6
@JKatzwinkel
Good to see that you can use the videos endpoint to grab that extra info though it's annoying it's not included in the search items.
I had a look at grabbing channel uploads. The easiest way I can see of doing this is:
Step 1: GET request to https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername=monstercatmedia&fields=items%2FcontentDetails
Returns:
{
"items": [
{
"contentDetails": {
"relatedPlaylists": {
"likes": "LLJ6td3C9QlPO9O_J5dF4ZzA",
"favorites": "FLJ6td3C9QlPO9O_J5dF4ZzA",
"uploads": "UUJ6td3C9QlPO9O_J5dF4ZzA"
},
"googlePlusUserId": "109256493672759116762"
}
}
]
}
Step 2: GET request to https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails%2Csnippet&playlistId=UUJ6td3C9QlPO9O_J5dF4ZzA
Returns (truncated to only show one item):
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/fgpGhgiWmwxeuQXhdDg_uqZsC1Q\"",
"nextPageToken": "CDIQAA",
"pageInfo": {
"totalResults": 650,
"resultsPerPage": 50
},
"items": [
{
"kind": "youtube#playlistItem",
"etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/UsP9M4B4N4xIf5FuiPXUQ3rBcSQ\"",
"id": "UUTIu2cnPopwhu13Y42miXAL1EP_jSpAy0",
"snippet": {
"publishedAt": "2015-05-08T05:27:37.000Z",
"channelId": "UCJ6td3C9QlPO9O_J5dF4ZzA",
"title": "[Trance] - Trivecta - Evaporate (feat. Aloma Steele) [Monstercat Release]",
"description": "Support on iTunes: http://monster.cat/1EovKiV\nSupport on Beatport: http://monster.cat/1zKsUZV\nSupport on Bandcamp: http://monster.cat/1KqNrD6\n---\nListen on SoundCloud: http://monster.cat/1KRT91H\nListen on Spotify: http://monster.cat/1GTKBUb\n\n▼ Follow Monstercat\nYouTube: http://www.youtube.com/Monstercat\nSpotify: http://monster.cat/1hGrCWk\nFacebook: http://facebook.com/Monstercat\nTwitter: http://twitter.com/Monstercat\nInstagram: http://instagram.com/monstercat\nVine: https://vine.co/monstercat\nSoundCloud: http://soundcloud.com/Monstercat\nGoogle+: https://plus.google.com/+Monstercat\nMonstercat FM: http://live.monstercat.com\n\n▼ Follow Trivecta\nFacebook: http://facebook.com/trivectamusic\nTwitter: http://twitter.com/trivectamusic\nSoundcloud: http://soundcloud.com/trivectamusic\nYoutube: http://www.youtube.com/trivectamusic\n\n▼ Follow Aloma Steele\nFacebook: http://www.facebook.com/alomasteele\nTwitter: http://twitter.com/AlomaSteele \nSoundcloud: http://soundcloud.com/alomasteele \nYoutube: http://www.youtube.com/user/LomaTherapy\nInstagram: https://instagram.com/alomasteele\n\n▼ Want some new Merchandise?\nhttp://monster.cat/MonstercatShop\n-----------------------------------\nWant to use this song in your own videos? Please go to: http://monster.cat/YouTube_License",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/1eXGv_wa7DE/default.jpg",
"width": 120,
"height": 90
},
"medium": {
"url": "https://i.ytimg.com/vi/1eXGv_wa7DE/mqdefault.jpg",
"width": 320,
"height": 180
},
"high": {
"url": "https://i.ytimg.com/vi/1eXGv_wa7DE/hqdefault.jpg",
"width": 480,
"height": 360
},
"standard": {
"url": "https://i.ytimg.com/vi/1eXGv_wa7DE/sddefault.jpg",
"width": 640,
"height": 480
}
},
"channelTitle": "Monstercat",
"playlistId": "UUJ6td3C9QlPO9O_J5dF4ZzA",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "1eXGv_wa7DE"
}
},
"contentDetails": {
"videoId": "1eXGv_wa7DE"
}
Step 3: GET request to https://www.googleapis.com/youtube/v3/videos to get the duration of the videos (see above comments).
Three HTTP requests - not sure if anyone can get lower than that? I think you could probably get it in one if you scraped :P
Thanks for the advice and for placing confidence in my skills, @lol768 , but I have so far failed to find a way with less requests involved. I have in fact come up with nearly the same queries as you are suggesting, even though yours seem to yield more compact responses. What is best practice regarding the API key issue btw? Should users be expected to provide their own key? How would that look like? @ids1024 @np1 jkatzwinkel/mps-youtube@218925ef5c94e24e4612ef5ef6c263fc981dc5ab
Probably the app should provide an api key. I guess it should use the same key as pafy, which could be obtained by using pafy.api_key
(after pafy is changed to use gdata v3, of course).
Requiring two requests is not too bad since it seems fairly fast. I didn't take the time to look at the api for that, and was concerned it would require a request for each video.
@JKatzwinkel Github is not recognizing your commits as yours since you do not have an actual email set up with git. This is not really an issue, but you should probably run git config --global user.email EMAIL_YOUR_GITHUB_ACCOUNT_USES
. Or if you want to keep your email address private:
https://help.github.com/articles/keeping-your-email-address-private/
This is seriously a big problem, my life is over. I wont be able to work until this is fixed, I cant risk opening youtube in a browser and risk being distracted!!
I appreciate the hard work on this problem. I run no windows manager, just Xterm + tmux, so mps-youtube is really essential ;) Thanks
@laapsaap Try using PR #256. It's incomplete, but a lot of the basic functionality seems to be working fine.
pip install --upgrade https://github.com/ids1024/mps-youtube/archive/gdata3wip.zip
till it's merged
Thanks @ids1024 !!
When I search a video, one result appear : 1 https://youtube.com/devicesupport 03:56 But playlists research displays well.