2019-04-15 02:04:08 +02:00
|
|
|
# coding: utf-8
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2019-04-18 23:42:34 +02:00
|
|
|
from ..utils import (
|
|
|
|
int_or_none,
|
|
|
|
RegexNotFoundError,
|
|
|
|
)
|
2019-04-15 02:04:08 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ChangbaIE(InfoExtractor):
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?changba\.com/s/(?P<id>[0-9A-Za-z-_]+)'
|
2019-04-15 22:38:29 +02:00
|
|
|
_TESTS = [{
|
2019-04-15 02:04:08 +02:00
|
|
|
'url': 'https://changba.com/s/0GHVw6vyXv9N2FhaFi2WJg',
|
2019-04-15 22:38:29 +02:00
|
|
|
'md5': 'ea55d17e939f3e2dabf483e47e8e5693',
|
2019-04-15 02:04:08 +02:00
|
|
|
'info_dict': {
|
|
|
|
'id': '1152860688',
|
|
|
|
'ext': 'mp4',
|
2019-04-15 22:38:29 +02:00
|
|
|
'title': '对你爱不完【炫酷慢摇】 ',
|
2019-04-15 02:04:08 +02:00
|
|
|
}
|
2019-04-15 23:43:21 +02:00
|
|
|
}, {
|
2019-04-15 22:38:29 +02:00
|
|
|
'url': 'http://changba.com/s/nZqfbS_vCnieNNjJ7UiEGw?',
|
|
|
|
'md5': 'e401463ffb03ed8900a0bccc641335e1',
|
|
|
|
'info_dict': {
|
|
|
|
'id': '1091968526',
|
|
|
|
'ext': 'mp3',
|
|
|
|
'title': '下雪 ',
|
|
|
|
}
|
2019-04-15 23:43:21 +02:00
|
|
|
}, {
|
2019-04-15 23:21:51 +02:00
|
|
|
'url': 'http://changba.com/s/CPiNWbAa1qy0po0llqIJbg',
|
2019-04-15 23:38:36 +02:00
|
|
|
'md5': '7adcc9afb85ace8ff854bdd0e8567f50',
|
2019-04-15 23:21:51 +02:00
|
|
|
'info_dict': {
|
|
|
|
'id': '136918054',
|
|
|
|
'ext': 'mp3',
|
|
|
|
'title': '红豆 ',
|
|
|
|
}
|
2019-04-15 22:38:29 +02:00
|
|
|
}]
|
2019-04-15 02:04:08 +02:00
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
id = self._search_regex(r'workid=([0-9]+)', webpage, 'id')
|
2019-04-17 01:53:21 +02:00
|
|
|
title = self._search_regex(
|
|
|
|
r'<div[^>]+class="title"[^>]*>([^<]+)', webpage, 'title'
|
|
|
|
)
|
2019-04-18 23:31:18 +02:00
|
|
|
# title = self._og_search_title(webpage)
|
|
|
|
is_video = self._search_regex(r'&isvideo=([0-9])', webpage, 'isvideo')
|
|
|
|
ext = 'mp3' if int_or_none(is_video) == 0 else 'mp4'
|
2019-04-15 02:04:08 +02:00
|
|
|
|
2019-04-15 23:02:55 +02:00
|
|
|
try:
|
2019-04-17 01:29:41 +02:00
|
|
|
src_url = self._search_regex(r'var a="([^"]*)', webpage, 'url')
|
2019-04-18 23:42:34 +02:00
|
|
|
except RegexNotFoundError:
|
2019-04-18 23:31:18 +02:00
|
|
|
src_url = 'http://lzscuw.changba.com/' + str(id) + '.' + ext
|
2019-04-15 02:04:08 +02:00
|
|
|
|
|
|
|
return {
|
2019-04-17 01:29:41 +02:00
|
|
|
'url': src_url,
|
2019-04-15 02:04:08 +02:00
|
|
|
'id': id,
|
|
|
|
'ext': ext,
|
2019-04-15 23:38:36 +02:00
|
|
|
'title': title,
|
2019-04-15 02:04:08 +02:00
|
|
|
}
|