From b6d125ed5c997a3a0dd19248ad29763af60a9820 Mon Sep 17 00:00:00 2001 From: rogerchang23424 <31232283+rogerchang23424@users.noreply.github.com> Date: Thu, 14 Sep 2017 18:23:58 +0800 Subject: [PATCH 1/4] Update xuite.py --- youtube_dl/extractor/xuite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/xuite.py b/youtube_dl/extractor/xuite.py index 0276c0dbb..bdf74f99a 100644 --- a/youtube_dl/extractor/xuite.py +++ b/youtube_dl/extractor/xuite.py @@ -107,7 +107,7 @@ class XuiteIE(InfoExtractor): video_id = media_info['MEDIA_ID'] formats = [] - for key in ('html5Url', 'html5HQUrl'): + for key in ('html5Url', 'html5HQUrl', 'html5HQUrl2'): video_url = media_info.get(key) if not video_url: continue From eb8fbda63cb4c8f69b00503126f188b2757a8b2d Mon Sep 17 00:00:00 2001 From: rogerchang23424 <31232283+rogerchang23424@users.noreply.github.com> Date: Fri, 15 Sep 2017 15:01:52 +0800 Subject: [PATCH 2/4] Add files via upload --- youtube_dl/extractor/anigamer.py | 87 ++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 youtube_dl/extractor/anigamer.py diff --git a/youtube_dl/extractor/anigamer.py b/youtube_dl/extractor/anigamer.py new file mode 100644 index 000000000..6f80b65aa --- /dev/null +++ b/youtube_dl/extractor/anigamer.py @@ -0,0 +1,87 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + +from ..utils import ExtractorError + +import json +import math +import random + + +class AniGamerIE(InfoExtractor): + _VALID_URL = r'https?://ani\.gamer\.com\.tw/animeVideo\.php\?sn=(?P[0-9]+)' + _TEST = { + 'url': 'https://yourextractor.com/watch/42', + 'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', + 'info_dict': { + 'id': '42', + 'ext': 'mp4', + 'title': 'Video title goes here', + 'thumbnail': r're:^https?://.*\.jpg$', + # TODO more properties, either as: + # * A value + # * MD5 checksum; start the string with md5: + # * A regular expression; start the string with re: + # * Any Python type (for example int or float) + } + } + + def _real_extract(self, url): + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + info = {'id': video_id} + + device_id_json = self._download_json('https://ani.gamer.com.tw/ajax/getdeviceid.php', video_id, + note='Get device id', query={'id': ''}) + + if device_id_json.get('deviceid'): + device_id = device_id_json.get('deviceid') + else: + self.report_warning('Warning! Cannot get device id', video_id) + + title = self._html_search_regex('

(.+?)

', webpage, 'title') + info['title'] = title + + ad_js = self._download_webpage('https://i2.bahamut.com.tw/JS/ad/animeVideo2.js', video_id, ) + + minor_code = self._search_regex(r'var\s+getMinorAd\s*=\s*function\(\)\s*\{(?P[^}]+)\};', ad_js, 'code') + + ad_list_s = self._search_regex(r'var\s+adlist\s*=\s*(?P\[(.+?)\]);', minor_code, 'list') + ad_list = json.loads(ad_list_s) + del minor_code + del ad_list_s + + ik = math.floor(9 * random.random()) + + ad_sid = ad_list[ik][2] + ad_query = { + 's': ad_sid, + 'sn': video_id + } + self._download_webpage('https://ani.gamer.com.tw/ajax/videoCastcishu.php', video_id, query=ad_query) + + ad_query['ad'] = 'end' + self._download_webpage('https://ani.gamer.com.tw/ajax/videoCastcishu.php', video_id, query=ad_query) + + m3u8_query = { + 'sn': video_id, + 'device': device_id + } + + m3u8_json = self._download_json('https://ani.gamer.com.tw/ajax/m3u8.php', video_id, query=m3u8_query) + + if 'error' in m3u8_json: + raise ExtractorError('Cannot extract URL.') + + index_m3u8_url = m3u8_json.get('src') + + if index_m3u8_url[0:2] == '//': + index_m3u8_url = 'https:' + index_m3u8_url + + formats = self._extract_m3u8_formats(index_m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native') + + info['formats'] = formats + + return info \ No newline at end of file From b271fde4595e34db554d40b0ff383034ed3756f7 Mon Sep 17 00:00:00 2001 From: rogerchang23424 <31232283+rogerchang23424@users.noreply.github.com> Date: Fri, 15 Sep 2017 17:57:47 +0800 Subject: [PATCH 3/4] Add files via upload --- youtube_dl/extractor/anigamer.py | 33 +++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/youtube_dl/extractor/anigamer.py b/youtube_dl/extractor/anigamer.py index 6f80b65aa..d2b7fd27d 100644 --- a/youtube_dl/extractor/anigamer.py +++ b/youtube_dl/extractor/anigamer.py @@ -8,10 +8,15 @@ from ..utils import ExtractorError import json import math import random +import re class AniGamerIE(InfoExtractor): _VALID_URL = r'https?://ani\.gamer\.com\.tw/animeVideo\.php\?sn=(?P[0-9]+)' + + _ANI_BASE = 'https://ani.gamer.com.tw' + _I2_BASE = 'https://i2.bahamut.com.tw' + _TEST = { 'url': 'https://yourextractor.com/watch/42', 'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', @@ -33,18 +38,27 @@ class AniGamerIE(InfoExtractor): webpage = self._download_webpage(url, video_id) info = {'id': video_id} - device_id_json = self._download_json('https://ani.gamer.com.tw/ajax/getdeviceid.php', video_id, - note='Get device id', query={'id': ''}) + str_info = self._html_search_regex(r']+type="application/ld\+json"[^>]*>(?P[^<]+)', webpage, 'code') + video_info = json.loads(str_info) + + info['description'] = video_info[2].get('description') + info['title'] = video_info[2].get('name') + info['interaction_count'] = video_info[2].get('interactionCount') + info['thumbnail'] = video_info[2].get('thumbnailUrl') + + if video_info[2].get('uploadDate'): + dmoj = re.search(r'(?P[0-9]+)-(?P[0-9]+)-(?P[0-9]+)T', video_info[2]['uploadDate']) + info['upload_date'] = dmoj.group('y') + dmoj.group('m') + dmoj.group('d') + + device_id_json = self._download_json('%s/ajax/getdeviceid.php' % self._ANI_BASE, video_id, + note='Getting device id', query={'id': ''}) if device_id_json.get('deviceid'): device_id = device_id_json.get('deviceid') else: self.report_warning('Warning! Cannot get device id', video_id) - title = self._html_search_regex('

(.+?)

', webpage, 'title') - info['title'] = title - - ad_js = self._download_webpage('https://i2.bahamut.com.tw/JS/ad/animeVideo2.js', video_id, ) + ad_js = self._download_webpage('%s/JS/ad/animeVideo2.js' % self._I2_BASE, video_id, ) minor_code = self._search_regex(r'var\s+getMinorAd\s*=\s*function\(\)\s*\{(?P[^}]+)\};', ad_js, 'code') @@ -60,17 +74,18 @@ class AniGamerIE(InfoExtractor): 's': ad_sid, 'sn': video_id } - self._download_webpage('https://ani.gamer.com.tw/ajax/videoCastcishu.php', video_id, query=ad_query) + self._download_webpage('%s/ajax/videoCastcishu.php' % self._ANI_BASE, video_id, + note='Skipping ad', query=ad_query) ad_query['ad'] = 'end' - self._download_webpage('https://ani.gamer.com.tw/ajax/videoCastcishu.php', video_id, query=ad_query) + self._download_webpage('%s/ajax/videoCastcishu.php' % self._ANI_BASE, video_id, note='Skipping ad', query=ad_query) m3u8_query = { 'sn': video_id, 'device': device_id } - m3u8_json = self._download_json('https://ani.gamer.com.tw/ajax/m3u8.php', video_id, query=m3u8_query) + m3u8_json = self._download_json('%s/ajax/m3u8.php' % self._ANI_BASE, video_id, query=m3u8_query) if 'error' in m3u8_json: raise ExtractorError('Cannot extract URL.') From ce3f76d233d951b67802d8c37e10f6ff3133343c Mon Sep 17 00:00:00 2001 From: rogerchang23424 <31232283+rogerchang23424@users.noreply.github.com> Date: Mon, 18 Sep 2017 16:57:00 +0800 Subject: [PATCH 4/4] Add files via upload --- youtube_dl/extractor/anigamer.py | 36 +++++++++++++++++------------- youtube_dl/extractor/extractors.py | 2 ++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/youtube_dl/extractor/anigamer.py b/youtube_dl/extractor/anigamer.py index d2b7fd27d..51be79155 100644 --- a/youtube_dl/extractor/anigamer.py +++ b/youtube_dl/extractor/anigamer.py @@ -11,27 +11,31 @@ import random import re -class AniGamerIE(InfoExtractor): +class AnimeBahamutIE(InfoExtractor): _VALID_URL = r'https?://ani\.gamer\.com\.tw/animeVideo\.php\?sn=(?P[0-9]+)' _ANI_BASE = 'https://ani.gamer.com.tw' _I2_BASE = 'https://i2.bahamut.com.tw' - _TEST = { - 'url': 'https://yourextractor.com/watch/42', - 'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', + _TESTS = [{ + 'url': 'https://ani.gamer.com.tw/animeVideo.php?sn=90', 'info_dict': { - 'id': '42', + 'id': '90', 'ext': 'mp4', - 'title': 'Video title goes here', - 'thumbnail': r're:^https?://.*\.jpg$', - # TODO more properties, either as: - # * A value - # * MD5 checksum; start the string with md5: - # * A regular expression; start the string with re: - # * Any Python type (for example int or float) + 'title': '冰菓[1]', + 'thumbnail': 'https://p2.bahamut.com.tw/B/2KU/11/0001306611.JPG', + 'description': '追求灰色校園生活的消極少年、與充滿好奇心又積極的少女在即將倒閉的古典社相遇了,他們的相遇是會帶來怎麼樣的青春生活呢?改編自米澤穗信古典社系列的同名原作《冰菓》,由京都動畫所製作的動畫作品《冰菓》已於今年春季開播。 這次《冰菓》的監督是擔任過《驚爆危機 校園篇》、《涼宮春日的消失》監督的 武本康弘。武本監' } - } + }, { + 'url': 'https://ani.gamer.com.tw/animeVideo.php?sn=4243', + 'info_dict': { + 'id': '4243', + 'ext': 'mp4', + 'title': '無法掙脫的背叛[1]', + 'thumbnail': 'https://p2.bahamut.com.tw/B/2KU/26/0001309926.JPG', + 'description': '主角是在孤兒院長大的高中生「櫻井夕月」,而他擁有在觸碰人時能讀取他人記憶與思緒的特殊能力。某日,在他的面前出現了一位似曾相識、並讓他感到有點懷念的美貌青年「桀斯」,而桀斯也向夕月提出忠告,絕對不要在召喚死亡的紅月之夜「瓦爾波吉斯之夜」外出。 之後的某天,名為「祗王天白」的人拜訪了夕月,並告訴夕月他是' + } + }] def _real_extract(self, url): video_id = self._match_id(url) @@ -67,7 +71,7 @@ class AniGamerIE(InfoExtractor): del minor_code del ad_list_s - ik = math.floor(9 * random.random()) + ik = int(math.floor(9 * random.random())) ad_sid = ad_list[ik][2] ad_query = { @@ -75,10 +79,10 @@ class AniGamerIE(InfoExtractor): 'sn': video_id } self._download_webpage('%s/ajax/videoCastcishu.php' % self._ANI_BASE, video_id, - note='Skipping ad', query=ad_query) + query=ad_query) ad_query['ad'] = 'end' - self._download_webpage('%s/ajax/videoCastcishu.php' % self._ANI_BASE, video_id, note='Skipping ad', query=ad_query) + self._download_webpage('%s/ajax/videoCastcishu.php' % self._ANI_BASE, video_id, query=ad_query) m3u8_query = { 'sn': video_id, diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index aefadc56f..1e4101ad2 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -1350,3 +1350,5 @@ from .zapiks import ZapiksIE from .zaq1 import Zaq1IE from .zdf import ZDFIE, ZDFChannelIE from .zingmp3 import ZingMp3IE + +from .anigamer import AnimeBahamutIE \ No newline at end of file