|
1 | 1 | # coding: utf-8
|
2 | 2 | from __future__ import unicode_literals
|
3 | 3 |
|
4 |
| -import hashlib |
5 |
| - |
6 | 4 | from .common import InfoExtractor
|
7 | 5 | from ..compat import (
|
8 | 6 | compat_parse_qs,
|
9 |
| - compat_urllib_request, |
10 |
| - compat_urlparse, |
11 | 7 | )
|
12 | 8 | from ..utils import (
|
13 | 9 | ExtractorError,
|
14 | 10 | sanitized_Request,
|
| 11 | + traverse_obj, |
15 | 12 | urlencode_postdata,
|
| 13 | + urljoin, |
16 | 14 | )
|
17 | 15 |
|
18 | 16 |
|
@@ -82,41 +80,32 @@ def _real_extract(self, url):
|
82 | 80 | self._downloader.cookiejar.clear_session_cookies() # must clear
|
83 | 81 | self._login()
|
84 | 82 |
|
85 |
| - title = 'FC2 video %s' % video_id |
86 |
| - thumbnail = None |
| 83 | + title, thumbnail, description = None, None, None |
87 | 84 | if webpage is not None:
|
88 |
| - title = self._og_search_title(webpage) |
| 85 | + title = self._html_search_regex( |
| 86 | + (r'<h2\s+class="videoCnt_title">([^<]+?)</h2>', |
| 87 | + r'\s+href="[^"]+"\s*title="([^"]+?)"\s*rel="nofollow">\s*<img', |
| 88 | + # there's two matches in the webpage |
| 89 | + r'\s+href="[^"]+"\s*title="([^"]+?)"\s*rel="nofollow">\s*\1'), |
| 90 | + webpage, |
| 91 | + 'title', fatal=False) |
89 | 92 | thumbnail = self._og_search_thumbnail(webpage)
|
90 |
| - refer = url.replace('/content/', '/a/content/') if '/a/content/' not in url else url |
91 |
| - |
92 |
| - mimi = hashlib.md5((video_id + '_gGddgPfeaf_gzyr').encode('utf-8')).hexdigest() |
93 |
| - |
94 |
| - info_url = ( |
95 |
| - 'http://video.fc2.com/ginfo.php?mimi={1:s}&href={2:s}&v={0:s}&fversion=WIN%2011%2C6%2C602%2C180&from=2&otag=0&upid={0:s}&tk=null&'. |
96 |
| - format(video_id, mimi, compat_urllib_request.quote(refer, safe=b'').replace('.', '%2E'))) |
97 |
| - |
98 |
| - info_webpage = self._download_webpage( |
99 |
| - info_url, video_id, note='Downloading info page') |
100 |
| - info = compat_urlparse.parse_qs(info_webpage) |
| 93 | + description = self._og_search_description(webpage) |
101 | 94 |
|
102 |
| - if 'err_code' in info: |
103 |
| - # most of the time we can still download wideo even if err_code is 403 or 602 |
104 |
| - self.report_warning( |
105 |
| - 'Error code was: %s... but still trying' % info['err_code'][0]) |
106 |
| - |
107 |
| - if 'filepath' not in info: |
108 |
| - raise ExtractorError('Cannot download file. Are you logged in?') |
109 |
| - |
110 |
| - video_url = info['filepath'][0] + '?mid=' + info['mid'][0] |
111 |
| - title_info = info.get('title') |
112 |
| - if title_info: |
113 |
| - title = title_info[0] |
| 95 | + vidplaylist = self._download_json( |
| 96 | + 'https://video.fc2.com/api/v3/videoplaylist/%s?sh=1&fs=0' % video_id, video_id, |
| 97 | + note='Downloading info page') |
| 98 | + vid_url = traverse_obj(vidplaylist, ('playlist', 'nq')) |
| 99 | + if not vid_url: |
| 100 | + raise ExtractorError('Unable to extract video URL') |
| 101 | + vid_url = urljoin('https://video.fc2.com/', vid_url) |
114 | 102 |
|
115 | 103 | return {
|
116 | 104 | 'id': video_id,
|
117 | 105 | 'title': title,
|
118 |
| - 'url': video_url, |
119 |
| - 'ext': 'flv', |
| 106 | + 'url': vid_url, |
| 107 | + 'ext': 'mp4', |
| 108 | + 'description': description, |
120 | 109 | 'thumbnail': thumbnail,
|
121 | 110 | }
|
122 | 111 |
|
|
0 commit comments