Repository: ytdl-org/youtube-dl

Issue:
VEVO: HTTP Error 404
## Please follow the guide below

- You will be asked some questions and requested to provide some information, please read them **carefully** and answer honestly
- Put an `x` into all the boxes [ ] relevant to your *issue* (like that [x])
- Use *Preview* tab to see how your issue will actually look like

---

### Make sure you are using the *latest* version: run `youtube-dl --version` and ensure your version is *2017.04.03*. If it's not read [this FAQ entry](https://github.com/rg3/youtube-dl/blob/master/README.md#how-do-i-update-youtube-dl) and update. Issues with outdated version will be rejected.
- [x] I've **verified** and **I assure** that I'm running youtube-dl **2017.04.03**

### Before submitting an *issue* make sure you have:
- [x] At least skimmed through [README](https://github.com/rg3/youtube-dl/blob/master/README.md) and **most notably** [FAQ](https://github.com/rg3/youtube-dl#faq) and [BUGS](https://github.com/rg3/youtube-dl#bugs) sections
- [x] [Searched](https://github.com/rg3/youtube-dl/search?type=Issues) the bugtracker for similar issues including closed ones

### What is the purpose of your *issue*?
- [x] Bug report (encountered problems with youtube-dl)
- [ ] Site support request (request for adding support for a new site)
- [ ] Feature request (request for a new functionality)
- [ ] Question
- [ ] Other

---

### The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your *issue*

---

### If the purpose of this *issue* is a *bug report*, *site support request* or you are not completely sure provide the full verbose output as follows:

Add `-v` flag to **your command line** you run youtube-dl with, copy the **whole** output and insert it here. It should look similar to one below (replace it with **your** log inserted between triple ```):
```
youtube-dl --verbose https://www.vevo.com/watch/wizkid/come-closer/USRV81700159
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'--verbose', u'https://www.vevo.com/watch/wizkid/come-closer/USRV81700159']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.04.03
[debug] Python version 2.7.9 - Darwin-13.4.0-x86_64-i386-64bit
[debug] exe versions: none
[debug] Proxy map: {}
[Vevo] Retrieving oauth token
ERROR: Unable to retrieve oauth token: HTTP Error 404: Not Found (caused by HTTPError()); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
  File "/usr/local/bin/youtube-dl/youtube_dl/extractor/common.py", line 498, in _request_webpage
    return self._downloader.urlopen(url_or_request)
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 2100, in urlopen
    return self._opener.open(req, timeout=self._socket_timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 469, in error
    result = self._call_chain(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 656, in http_error_302
    return self.parent.open(new, timeout=req.timeout)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)

<end of log>
```

---

### If the purpose of this *issue* is a *site support request* please provide all kinds of example URLs support for which should be included (replace following example URLs by **yours**):
- Single video: https://www.youtube.com/watch?v=BaW_jenozKc
- Single video: https://youtu.be/BaW_jenozKc
- Playlist: https://www.youtube.com/playlist?list=PL4lCao7KL_QFVb7Iudeipvc2BCavECqzc

Note that **youtube-dl does not support sites dedicated to [copyright infringement](https://github.com/rg3/youtube-dl#can-you-add-support-for-this-anime-video-site-or-site-which-shows-current-movies-for-free)**. In order for site support request to be accepted all provided example URLs should not violate any copyrights.

---

### Description of your *issue*, suggested solution and other information

Explanation of your *issue* in arbitrary form goes here. Please make sure the [description is worded well enough to be understood](https://github.com/rg3/youtube-dl#is-the-description-of-the-issue-itself-sufficient). Provide as much context and examples as possible.
If work on your *issue* requires account credentials please provide them or explain how one can obtain them.



Discussion:
Can reproduce...
To anybody fixing it: there is huge chunk of JSON after `window.__INITIAL_STORE__=`. 

This should help:

```python
data = json_chunk['apollo']['data']
info = data[video_id]
likes = info.get('likes', None)

meta_tag = info.get('basicMetaV3', {}).get('id', None)
views_tag = info.get('views', {}).get('id', None)
streams_tags = [x['id'] for x in info['streamsV3']]

meta = data.get(meta_tag, {})

title = meta.get('title', None)
thumbnail = meta.get('thumbnailUrl', None)
duration = meta.get('duration', None)
views = data.get(views_tag, {}).get('viewsTotal', None)

streams = [data[x] for x in streams_tags]
```
Currently, the only possible way to download videos from Vevo, is to use Firefox's DownloadHelper, and extract the m3u8 playlist url.  Here is an example.

https://hls-aws.vevo.com/v3/hls/2017/04/USUV71700843/0b6da121-4b67-4285-b2e4-12c6daa86128/5200/usuv71700843_5200k_1920x1080_h264_5200_aac_128.m3u8

I hope this helps you guys in being able to make it possible to download from the main video urls.
>  Firefox's DownloadHelper

Do you mean this one?
https://addons.mozilla.org/en-US/firefox/addon/video-downloadhelper/?src=hp-dl-mostpopular
@Hrxn Yes.
I found another way to download the videos.  On Firefox or Chrome, on a video page, view the page's source code, and Ctrl+F for ".m3u8".  Copy this link and use -F to look up available formats, and we should be able to download.
@goldensun87 The outputted video stutters with that plugin.  Also, what's the string for formats with vevo?  I tried your other solution (the CTRL+F) and I get:

youtube-dl -f http://hls-video.vevo.com/v3/hls/2017/04/QM4HH1720003/20d88bb4-41c6-436c-aee0-d0004d2be370/index.m3u8
Usage: youtube-dl [OPTIONS] URL [URL...]

youtube-dl: error: You must provide at least one URL.
Type youtube-dl --help to see a list of all options.
`youtube-dl -F` not `youtube-dl -f`, which is followed by its parameter which is the URL you posted in your case.
Ok so, it looks like Downloadhelper is able to pull up the format-specific playlist urls, while the playlist url available in the source code, is more like a "nest" of links containing the urls for all the available formats.  I will post both links for quick comparison.

http://hls-video.vevo.com/v3/hls/2017/04/USUV71700843/0b6da121-4b67-4285-b2e4-12c6daa86128/index.m3u8

https://hls-aws.vevo.com/v3/hls/2017/04/USUV71700843/0b6da121-4b67-4285-b2e4-12c6daa86128/5200/usuv71700843_5200k_1920x1080_h264_5200_aac_128.m3u8

When using a link like the former above, I recommend using -F to look up all available formats.  Users could just use "youtube-dl [link]" like the developers recommend, and that would download by default, the format which the program detects as the "best" format, but people may want to download a smaller format.  For the latter link above, it is only one format, so feel free to use "youtube-dl [link]".

@g8keepa I tested both of the links which I posted, I did not experience any stuttering on my side.  And really, assuming you download the same resolution from the "nest" link, it really is the same stream.  What are your computer's specs?  It could be a hardware issue on your side.  Or maybe you should update your ffmpeg to the latest version, since ffmpeg is required to mux the fragments that Vevo videos are made up of.  You might be using a heavily outdated version.
@Hrxn Thank you, that helped immensely ... which leads to the following:

@goldensun87 Latest ffmpeg installed (made sure it was updated before I tried to pull the video).  Machine is a 2012 Macbook Pro i7 Quad (Ivy Bridge) w/ 16 GB of RAM.  It's not the latest and greatest, but I do video work on it all the time.  That being said, your solution with what @Hrxn suggested was perfect.

This will work in the interim until youtube-dl is updated.  Thanks guys!
Using the workaround for now (didn't work today until I updated).  While this is working for now, any word on this being fixed entirely?
Any updates?

Resolving patch:
diff --git a/youtube_dl/extractor/vevo.py b/youtube_dl/extractor/vevo.py
--- a/youtube_dl/extractor/vevo.py
+++ b/youtube_dl/extractor/vevo.py
@@ -1,6 +1,7 @@
 from __future__ import unicode_literals
 
 import re
+import json
 
 from .common import InfoExtractor
 from ..compat import (
@@ -154,8 +155,15 @@ class VevoIE(VevoBaseIE):
     }
 
     def _initialize_api(self, video_id):
+        post_data = json.dumps({
+            'client_id': 'SPupX1tvqFEopQ1YS6SS',
+            'grant_type': 'urn:vevo:params:oauth:grant-type:anonymous',
+        }).encode('utf-8')
+        headers = {
+            'Content-Type': 'application/json',
+        }
         req = sanitized_Request(
-            'http://www.vevo.com/auth', data=b'')
+            'https://accounts.vevo.com/token', post_data, headers)
         webpage = self._download_webpage(
             req, None,
             note='Retrieving oauth token',
@@ -166,7 +174,7 @@ def _initialize_api(self, video_id):
                 '%s said: This page is currently unavailable in your region' % self.IE_NAME)
 
         auth_info = self._parse_json(webpage, video_id)
-        self._api_url_template = self.http_scheme() + '//apiv2.vevo.com/%s?token=' + auth_info['access_token']
+        self._api_url_template = self.http_scheme() + '//apiv2.vevo.com/%s?token=' + auth_info['legacy_token']
 
     def _call_api(self, path, *args, **kwargs):
         try:


Test patch: