From 5069f20b50625d0e2b835b91ff0e285bf7fe07b0 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Wed, 21 Aug 2019 05:08:17 +0900 Subject: [PATCH 1/8] =?UTF-8?q?=E3=82=BF=E3=82=B0=E5=AF=BE=E5=BF=9C,=20ima?= =?UTF-8?q?ges=E5=AF=BE=E5=BF=9C,=20=E3=83=86=E3=82=B9=E3=83=88=E6=9B=B4?= =?UTF-8?q?=E6=96=B0,=20=E3=81=9D=E3=81=AE=E4=BB=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/IwaraResolver.php | 60 +- app/MetadataResolver/MetadataResolver.php | 2 +- .../MetadataResolver/IwaraResolverTest.php | 71 + tests/fixture/Iwara/images.html | 644 +++++++ tests/fixture/Iwara/video.html | 1713 +++++++++++++++++ tests/fixture/Iwara/youtube.html | 1013 ++++++++++ 6 files changed, 3468 insertions(+), 35 deletions(-) create mode 100644 tests/Unit/MetadataResolver/IwaraResolverTest.php create mode 100644 tests/fixture/Iwara/images.html create mode 100644 tests/fixture/Iwara/video.html create mode 100644 tests/fixture/Iwara/youtube.html diff --git a/app/MetadataResolver/IwaraResolver.php b/app/MetadataResolver/IwaraResolver.php index 361501d..f19efc9 100644 --- a/app/MetadataResolver/IwaraResolver.php +++ b/app/MetadataResolver/IwaraResolver.php @@ -3,6 +3,7 @@ namespace App\MetadataResolver; use GuzzleHttp\Client; +use Symfony\Component\DomCrawler\Crawler; class IwaraResolver implements Resolver { @@ -19,46 +20,37 @@ class IwaraResolver implements Resolver public function resolve(string $url): Metadata { $res = $this->client->get($url); - if ($res->getStatusCode() === 200) { - $dom = new \DOMDocument(); - @$dom->loadHTML(mb_convert_encoding($res->getBody(), 'HTML-ENTITIES', 'UTF-8')); - $xpath = new \DOMXPath($dom); - $metadata = new Metadata(); + $html = (string) $res->getBody(); + $crawler = new Crawler($html); - // find title - foreach ($xpath->query('//title') as $node) { - $content = $node->textContent; - if (!empty($content)) { - $metadata->title = $content; - break; + $descriptionElement = $crawler->filter('#video-player + div, .field-name-field-video-url + div, .field-name-field-images + div'); + $title = $descriptionElement->filter('h1.title')->text(); + $author = $descriptionElement->filter('.username')->text(); + $description = $descriptionElement->children('div')->eq(1)->text(); + $tags = $descriptionElement->filter('a[href^="/video-categories"], a[href^="/images"]')->extract('_text'); + + $metadata->title = $title; + $metadata->description = '投稿者: ' . $author . PHP_EOL . $description; + $metadata->tags = $tags; + + // iwara video + if ($crawler->filter('#video-player')->count()) { + $metadata->image = 'https:' . $crawler->filter('#video-player')->attr('poster'); + } + + // youtube + if ($crawler->filter('iframe[src^="//www.youtube.com"]')->count()) { + if (preg_match('~youtube\.com/embed/(\S+)\?~', $crawler->filter('iframe[src^="//www.youtube.com"]')->attr('src'), $matches) === 1) { + $youtubeId = $matches[1]; + $metadata->image = 'https://img.youtube.com/vi/' . $youtubeId . '/maxresdefault.jpg'; } } - // find thumbnail - foreach ($xpath->query('//*[@id="video-player"]') as $node) { - $poster = $node->getAttribute('poster'); - if (!empty($poster)) { - if (strpos($poster, '//') === 0) { - $poster = 'https:' . $poster; - } - $metadata->image = $poster; - break; - } - } - if (empty($metadata->image)) { - // YouTube embedded? - foreach ($xpath->query('//div[@class="embedded-video"]//iframe') as $node) { - $src = $node->getAttribute('src'); - if (preg_match('~youtube\.com/embed/(\S+)\?~', $src, $matches) !== -1) { - $youtubeId = $matches[1]; - $iwaraThumbUrl = 'https://i.iwara.tv/sites/default/files/styles/thumbnail/public/video_embed_field_thumbnails/youtube/' . $youtubeId . '.jpg'; - - $metadata->image = $iwaraThumbUrl; - break; - } - } + // images + if ($crawler->filter('.field-name-field-images')->count()) { + $metadata->image = 'https:' . $crawler->filter('.field-name-field-images a')->first()->attr('href'); } return $metadata; diff --git a/app/MetadataResolver/MetadataResolver.php b/app/MetadataResolver/MetadataResolver.php index e53f7d6..363b6f3 100644 --- a/app/MetadataResolver/MetadataResolver.php +++ b/app/MetadataResolver/MetadataResolver.php @@ -14,7 +14,7 @@ class MetadataResolver implements Resolver '~komiflo\.com(/#!)?/comics/(\\d+)~' => KomifloResolver::class, '~www\.melonbooks\.co\.jp/detail/detail\.php~' => MelonbooksResolver::class, '~ec\.toranoana\.(jp|shop)/(tora|joshi)(_[rd]+)?/(ec|digi)/item/~' => ToranoanaResolver::class, - '~iwara\.tv/videos/.*~' => IwaraResolver::class, + '~iwara\.tv/(videos|images)/.*~' => IwaraResolver::class, '~www\.dlsite\.com/.*/(work|announce)/=/product_id/..\d+(\.html)?~' => DLsiteResolver::class, '~dlsite\.jp/...tw/..\d+~' => DLsiteResolver::class, '~www\.pixiv\.net/member_illust\.php\?illust_id=\d+~' => PixivResolver::class, diff --git a/tests/Unit/MetadataResolver/IwaraResolverTest.php b/tests/Unit/MetadataResolver/IwaraResolverTest.php new file mode 100644 index 0000000..d8865b2 --- /dev/null +++ b/tests/Unit/MetadataResolver/IwaraResolverTest.php @@ -0,0 +1,71 @@ +shouldUseMock()) { + sleep(1); + } + } + + public function testVideo() + { + $responseText = file_get_contents(__DIR__ . '/../../fixture/Iwara/video.html'); + + $this->createResolver(IwaraResolver::class, $responseText); + + $url = 'https://ecchi.iwara.tv/videos/wqlwatgmvhqg40kg'; + $metadata = $this->resolver->resolve($url); + $this->assertEquals('Cakeface【鈴谷、プリンツ】', $metadata->title); + $this->assertEquals('投稿者: kuro@vov' . PHP_EOL . 'Thank you for watching!いつもありがとうございます' . PHP_EOL . 'こっそり微修正…' . PHP_EOL . 'Model:鈴谷&プリンツ つみだんご様 罪袋:BCD様' . PHP_EOL . '(いずれも改変)クレジット漏れゴメンナサイ。。。' . PHP_EOL, $metadata->description); + $this->assertEquals(['Uncategorized', 'KanColle'], $metadata->tags); + $this->assertEquals('https://i.iwara.tv/sites/default/files/videos/thumbnails/238591/thumbnail-238591_0004.jpg', $metadata->image); + if ($this->shouldUseMock()) { + $this->assertSame($url, (string) $this->handler->getLastRequest()->getUri()); + } + } + + public function testYouTube() + { + $responseText = file_get_contents(__DIR__ . '/../../fixture/Iwara/youtube.html'); + + $this->createResolver(IwaraResolver::class, $responseText); + + $url = 'https://iwara.tv/videos/z4dn6fag4iko08o0'; + $metadata = $this->resolver->resolve($url); + $this->assertEquals('むちむち天龍ちゃんで君色に染まる', $metadata->title); + $this->assertEquals('投稿者: kochira' . PHP_EOL . 'Ray-cast test. Still trying to figure out how Ray-cast works so I\'m sorry if anything looks off.' . PHP_EOL . 'Unauthorized reproduction prohibited (無断転載は禁止です/未經授權禁止複製)' . PHP_EOL, $metadata->description); + $this->assertEquals(['Uncategorized', 'KanColle'], $metadata->tags); + $this->assertEquals('https://img.youtube.com/vi/pvA5Db082yo/maxresdefault.jpg', $metadata->image); + if ($this->shouldUseMock()) { + $this->assertSame($url, (string) $this->handler->getLastRequest()->getUri()); + } + } + + public function testImages() + { + $responseText = file_get_contents(__DIR__ . '/../../fixture/Iwara/images.html'); + + $this->createResolver(IwaraResolver::class, $responseText); + + $url = 'https://iwara.tv/images/%E9%8F%A1%E9%9F%B3%E3%82%8A%E3%82%9318%E6%AD%B3'; + $metadata = $this->resolver->resolve($url); + $this->assertEquals('鏡音りん18歳', $metadata->title); + $this->assertEquals('投稿者: Tonjiru Lion' . PHP_EOL . '今回はあんまエロくないです。' . PHP_EOL, $metadata->description); + $this->assertEquals(['Vocaloid'], $metadata->tags); + $this->assertEquals('https://i.iwara.tv/sites/default/files/photos/jing_yin_rin18sui_a.png', $metadata->image); + if ($this->shouldUseMock()) { + $this->assertSame($url, (string) $this->handler->getLastRequest()->getUri()); + } + } +} diff --git a/tests/fixture/Iwara/images.html b/tests/fixture/Iwara/images.html new file mode 100644 index 0000000..eb48004 --- /dev/null +++ b/tests/fixture/Iwara/images.html @@ -0,0 +1,644 @@ + + + + 鏡音りん18歳 | Iwara + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ +
+ + +
+
+ + +
+
+
+
+ + + + +
+
+ + +
+
+
+
+
+ + +

今回はあんまエロくないです。

+
12,424
+
+ +
+ +
+ +
+ +
+
+

+ コメント数 6

+ + +
+ + +
+ + +
+

良いカスタムモデルですね
+ぶっちゃけ裸よりエロいです(*´ω`)

+
+ +
+
+ +
+ + +
+ + +
+

可愛いと思います!

+
+ +
+
+ +
+ + +
+ + +
+

これくらいの微エロも捗りますね

+
+ +
+
+ +
+ + +
+ + +
+

これはけしからん18歳

+
+ +
+
+ +
+ + +
+ + +
+

That is Nice!

+
+ +
+
+ +
+ + +
+ + +
+

Lovely! I wanna make her videos!! plz

+
+ +
+
+ +
+
+ + +
+
+
+ +
+
+
+ + + + + + + diff --git a/tests/fixture/Iwara/video.html b/tests/fixture/Iwara/video.html new file mode 100644 index 0000000..03fff45 --- /dev/null +++ b/tests/fixture/Iwara/video.html @@ -0,0 +1,1713 @@ + + + + Cakeface【鈴谷、プリンツ】 | Iwara + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ +
+ + +
+
+
+ + +
+
+
+
+ + + + +
+
+ + +
+
+
+ + + + +
+ + + +

Thank you for watching!いつもありがとうございます
+こっそり微修正…
+Model:鈴谷&プリンツ つみだんご様 罪袋:BCD様
+(いずれも改変)クレジット漏れゴメンナサイ。。。

+
+ 5966 742,707
+
+ +
+ + + ダウンロード + + + +
+ +
+ +
+
+
+ +
+
+

+ コメント数 213

+ + +
+ + +
+ + +
+

Thank you it's too great!!

+
+ +
+
+ +
+ + +
+ + +
+

NICE*N

+
+ +
+
+ +
+ + +
+ + +
+

good!

+
+ +
+
+ +
+ + +
+ + +
+

哇 又有 新的MMD了 先留言 感谢 UP

+
+ +
+
+ +
+
+ + +
+ + +
+

问下怎么下载啊……点了下载按钮弹出来一个空白页面

+
+ +
+
+ +
+
+ + +
+ + +
+

我是挂的SS 用IDM下载的。。 首先你的网络要支持 然后要用下载软件。

+
+ +
+
+
+
+ + +
+ + +
+

投稿お疲れ様です。素晴らしいです。kuroさんは間違いなく紳士MMD界の歴史に名を刻む人だ❗色んな事が凄すぎる。

+
+ +
+
+ +
+ + +
+ + +
+

Holy shit, your videos are seriously so damn good.

+
+ +
+
+ +
+ + +
+ + +
+

ちょっとこのクオリティはやばくないですかねぇ・・・・・・
+あっ、そこの人ティッシュ取って

+
+ +
+
+ +
+
+ + +
+ + +
+

あ、どうぞ (´・ω・`)つ

+
+ +
+
+
+
+ + +
+ + +
+

Thank you
+Nice video

+
+ +
+
+ +
+ + +
+ + +
+

投稿お疲れ!

+
+ +
+
+ +
+ + +
+ + +
+

お前がナンバーワンだ

+
+ +
+
+ +
+ + +
+ + +
+

ついから急いで来ました。
+す、素晴しい!!
+ぶらーーーぼぉーーー!
+ぶーーーらぁーーーぼぉーーー!

+
+ +
+
+ +
+ + +
+ + +
+

This is High End entertainment

+
+ +
+
+ +
+ + +
+ + +
+

素晴らしい動画をありがとうございます!

+
+ +
+
+ +
+ + +
+ + +
+

That is beautiful.

+
+ +
+
+ +
+ + +
+ + +
+

マジやばくね

+
+ +
+
+ +
+ + +
+ + +
+

Best Kancolle MMDer!

+
+ +
+
+ +
+ + +
+ + +
+

毎度素晴らしいクオリティとシコリティで実にありがたい…。

+
+ +
+
+ +
+ + +
+ + +
+

Amazing!
+Completely beyond comparison to any other work!

+
+ +
+
+ +
+ + +
+ + +
+

投稿お疲れ!

+
+ +
+
+ +
+ + +
+ + +
+

this is the best cakeface mmd i've ever seen

+
+ +
+
+ +
+ + +
+ + +
+

投稿お疲れ様です、エロイ・・・・スゴク・・・エロいです

+
+ +
+
+ +
+ + +
+ + +
+

石更火暴

+
+ +
+
+ +
+ + +
+ + +
+

This.. This is amazing!
+It's a masterpiece!!

+
+ +
+
+ +
+ + +
+ + +
+

新作ありがとうございます。

+
+ +
+
+ +
+ + +
+ + +
+

プリンツ ლ(゚д゚ლ)

+
+ +
+
+ +
+ + +
+ + +
+

Damn you are good! This is great!!

+
+ +
+
+ +
+ + +
+ + +
+

love the lighting

+
+ +
+
+ +
+ + +
+ + +
+

It's legendary! XD

+
+ +
+
+ +
+ + +
+ + +
+

great work

+
+ +
+
+ +
+ + +
+ + +
+

kuro@vov さんの動画はどれも素晴らしいのですが、今回のコレはずば抜けてすごい出来ですね…

+
+ +
+
+ +
+ + +
+ + +
+

投稿お疲れ様です!
+次は武蔵のが見たいな(チラッ

+
+ +
+
+ +
+ + +
+ + +
+

The best in which I've watched in 2 or 3 months.

+
+ +
+
+ +
+ + +
+ + +
+

素晴らしすぎます 

+
+ +
+
+ +
+ + +
+ + +
+

新上傳的MMD好棒!!!!!!!!!

+
+ +
+
+ +
+ + +
+ + +
+

相変わらず、素晴らしいの一言です、今夜は色々忙しくなりそうです

+
+ +
+
+ +
+ + +
+ + +
+

Amazing artwork!Such a masterpiece !

+
+ +
+
+ +
+ + +
+ + +
+

この二人に搾り取られたいw

+
+ +
+
+ +
+ + +
+ + +
+

MMDにおけるCakefaceをさらにエロく進化させる方が現れるとは…。
+ダンケ百唱モノです!

+
+ +
+
+ +
+ + +
+ + +
+

鈴谷んとプリンツに挟まれるなんて・・・なんて・・・何て贅沢なんだっ( ;∀;)

+
+ +
+
+ +
+ + +
+ + +
+

こちらこそいつも良い作品ありがとうございます!!

+
+ +
+
+ +
+ + +
+ + +
+

Good work,love it <3

+
+ +
+
+ +
+ + +
+ + +
+

これは…これは…素晴らしいだとしか言葉が出ないクォリティーですね。本当に素晴らしい作品です!

+
+ +
+
+ +
+ + +
+ + +
+

投稿お疲れ様です。すごいとしか言いようが無いですが、
+圧巻です。この技術と労力をかけてくださるkuroさんに
+感謝。

+
+ +
+
+ +
+ + +
+ + +
+

あっいつもの神様ですね分かります。

+
+ +
+
+ +
+ + +
+ + +
+

マジで格が違うすげぇ・・・

+
+ +
+
+ +
+ + +
+ + +
+

投稿お疲れ様です ありがとうございます

+
+ +
+
+ +
+ + +
+ + +
+

作品真的很用心,也非常好用,期待您更多的佳作。

+
+ +
+
+

ページ

+
+
+
+
+ +
+ +
+
+
+ + + + + + + + diff --git a/tests/fixture/Iwara/youtube.html b/tests/fixture/Iwara/youtube.html new file mode 100644 index 0000000..e646ffb --- /dev/null +++ b/tests/fixture/Iwara/youtube.html @@ -0,0 +1,1013 @@ + + + + むちむち天龍ちゃんで君色に染まる | Iwara + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+ +
+ +
+ + +
+
+
+ + +
+
+
+
+ + + + +
+
+ + +
+
+
+
+
+
+
+
+
+
+ + + +

Ray-cast test. Still trying to figure out how Ray-cast works so I'm sorry if anything looks off.

+

Unauthorized reproduction prohibited (無断転載は禁止です/未經授權禁止複製)

+
+ 240 37,644
+
+ +
+ + + + +
+ +
+ +
+
+
+ +
+
+

+ コメント数 17

+ + +
+ + +
+ + +
+

Wow, the Ray-cast looks great! I hope you do all of your videos like that. I have to add though I would prefer a Tenryuu with a skinnier waist and a smaller butt though. But beggars can't be choosers. T_T

+

Edit: And with her tits out!

+
+ +
+
+ +
+
+ + +
+ + +
+

I agree with your edit, comrade. Haha, I would love a nude version in the future :P

+
+ +
+
+ +
+ + +
+ + +
+

666666666

+
+ +
+
+
+
+ + +
+ + +
+

Looking real good :D And I don't know why, but I really like this thicc design of her. So... Fertile and healthy. GJ! She's super sexy (Reminds me of Kunaboto doujins, so lewd)

+
+ +
+
+ +
+ + +
+ + +
+

むちむち天龍!

+
+ +
+
+ +
+ + +
+ + +
+

Welcome back.

+
+ +
+
+ +
+ + +
+ + +
+

最高ですね。
+このモデルでもう1度NEW THANGが観たいです!

+
+ +
+
+ +
+ + +
+ + +
+

復活おめでとう

+
+ +
+
+ +
+ + +
+ + +
+

なんというお肉…埋もれたい('Д')

+
+ +
+
+ +
+ + +
+ + +
+

良い表情してるね
+すごく楽しそう

+
+ +
+
+ +
+ + +
+ + +
+

最高です!復活おめでとう

+
+ +
+
+ +
+ + +
+ + +
+

Yay welcome back Kochira nice video I love it lol.

+
+ +
+
+ +
+ + +
+ + +
+

Missed you <3

+
+ +
+
+ +
+ + +
+ + +
+

天龍ちゃん最高!

+
+ +
+
+ +
+ + +
+ + +
+

oh god!!! Uncensored version please!!! <3 this is so good GJ!!!

+
+ +
+
+ +
+ + +
+ + +
+

Very sexy♥♥

+
+ +
+
+ +
+ + +
+ + +
+

I hope to see a Uncensored version.

+
+ +
+
+ +
+
+
+
+ +
+ +
+
+
+ + + + + + + From 9926cc335742f435b4f60dbdf093aeb9b26ab6c4 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Thu, 22 Aug 2019 05:17:23 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=E5=BD=B9=E3=81=AB=E7=AB=8B=E3=81=9F?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=BF=E3=82=B0=E3=82=92=E5=90=AB=E3=82=81?= =?UTF-8?q?=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/IwaraResolver.php | 2 ++ tests/Unit/MetadataResolver/IwaraResolverTest.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/MetadataResolver/IwaraResolver.php b/app/MetadataResolver/IwaraResolver.php index f19efc9..29938d6 100644 --- a/app/MetadataResolver/IwaraResolver.php +++ b/app/MetadataResolver/IwaraResolver.php @@ -30,6 +30,8 @@ class IwaraResolver implements Resolver $author = $descriptionElement->filter('.username')->text(); $description = $descriptionElement->children('div')->eq(1)->text(); $tags = $descriptionElement->filter('a[href^="/video-categories"], a[href^="/images"]')->extract('_text'); + // 役に立たないタグを削除する + $tags = array_values(array_diff($tags, ['Uncategorized', 'Other'])); $metadata->title = $title; $metadata->description = '投稿者: ' . $author . PHP_EOL . $description; diff --git a/tests/Unit/MetadataResolver/IwaraResolverTest.php b/tests/Unit/MetadataResolver/IwaraResolverTest.php index d8865b2..ee19bb9 100644 --- a/tests/Unit/MetadataResolver/IwaraResolverTest.php +++ b/tests/Unit/MetadataResolver/IwaraResolverTest.php @@ -28,7 +28,7 @@ class IwaraResolverTest extends TestCase $metadata = $this->resolver->resolve($url); $this->assertEquals('Cakeface【鈴谷、プリンツ】', $metadata->title); $this->assertEquals('投稿者: kuro@vov' . PHP_EOL . 'Thank you for watching!いつもありがとうございます' . PHP_EOL . 'こっそり微修正…' . PHP_EOL . 'Model:鈴谷&プリンツ つみだんご様 罪袋:BCD様' . PHP_EOL . '(いずれも改変)クレジット漏れゴメンナサイ。。。' . PHP_EOL, $metadata->description); - $this->assertEquals(['Uncategorized', 'KanColle'], $metadata->tags); + $this->assertEquals(['KanColle'], $metadata->tags); $this->assertEquals('https://i.iwara.tv/sites/default/files/videos/thumbnails/238591/thumbnail-238591_0004.jpg', $metadata->image); if ($this->shouldUseMock()) { $this->assertSame($url, (string) $this->handler->getLastRequest()->getUri()); @@ -45,7 +45,7 @@ class IwaraResolverTest extends TestCase $metadata = $this->resolver->resolve($url); $this->assertEquals('むちむち天龍ちゃんで君色に染まる', $metadata->title); $this->assertEquals('投稿者: kochira' . PHP_EOL . 'Ray-cast test. Still trying to figure out how Ray-cast works so I\'m sorry if anything looks off.' . PHP_EOL . 'Unauthorized reproduction prohibited (無断転載は禁止です/未經授權禁止複製)' . PHP_EOL, $metadata->description); - $this->assertEquals(['Uncategorized', 'KanColle'], $metadata->tags); + $this->assertEquals(['KanColle'], $metadata->tags); $this->assertEquals('https://img.youtube.com/vi/pvA5Db082yo/maxresdefault.jpg', $metadata->image); if ($this->shouldUseMock()) { $this->assertSame($url, (string) $this->handler->getLastRequest()->getUri()); From 0a994884a03af92ec5d31379b8def98e54d114f0 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Thu, 22 Aug 2019 05:23:28 +0900 Subject: [PATCH 3/8] =?UTF-8?q?=E4=BD=9C=E8=80=85=E5=90=8D=E3=82=92?= =?UTF-8?q?=E3=82=BF=E3=82=B0=E3=81=AB=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/IwaraResolver.php | 1 + tests/Unit/MetadataResolver/IwaraResolverTest.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/MetadataResolver/IwaraResolver.php b/app/MetadataResolver/IwaraResolver.php index 29938d6..736b3ca 100644 --- a/app/MetadataResolver/IwaraResolver.php +++ b/app/MetadataResolver/IwaraResolver.php @@ -32,6 +32,7 @@ class IwaraResolver implements Resolver $tags = $descriptionElement->filter('a[href^="/video-categories"], a[href^="/images"]')->extract('_text'); // 役に立たないタグを削除する $tags = array_values(array_diff($tags, ['Uncategorized', 'Other'])); + array_push($tags, $author); $metadata->title = $title; $metadata->description = '投稿者: ' . $author . PHP_EOL . $description; diff --git a/tests/Unit/MetadataResolver/IwaraResolverTest.php b/tests/Unit/MetadataResolver/IwaraResolverTest.php index ee19bb9..453fdd7 100644 --- a/tests/Unit/MetadataResolver/IwaraResolverTest.php +++ b/tests/Unit/MetadataResolver/IwaraResolverTest.php @@ -28,7 +28,7 @@ class IwaraResolverTest extends TestCase $metadata = $this->resolver->resolve($url); $this->assertEquals('Cakeface【鈴谷、プリンツ】', $metadata->title); $this->assertEquals('投稿者: kuro@vov' . PHP_EOL . 'Thank you for watching!いつもありがとうございます' . PHP_EOL . 'こっそり微修正…' . PHP_EOL . 'Model:鈴谷&プリンツ つみだんご様 罪袋:BCD様' . PHP_EOL . '(いずれも改変)クレジット漏れゴメンナサイ。。。' . PHP_EOL, $metadata->description); - $this->assertEquals(['KanColle'], $metadata->tags); + $this->assertEquals(['KanColle', 'kuro@vov'], $metadata->tags); $this->assertEquals('https://i.iwara.tv/sites/default/files/videos/thumbnails/238591/thumbnail-238591_0004.jpg', $metadata->image); if ($this->shouldUseMock()) { $this->assertSame($url, (string) $this->handler->getLastRequest()->getUri()); @@ -45,7 +45,7 @@ class IwaraResolverTest extends TestCase $metadata = $this->resolver->resolve($url); $this->assertEquals('むちむち天龍ちゃんで君色に染まる', $metadata->title); $this->assertEquals('投稿者: kochira' . PHP_EOL . 'Ray-cast test. Still trying to figure out how Ray-cast works so I\'m sorry if anything looks off.' . PHP_EOL . 'Unauthorized reproduction prohibited (無断転載は禁止です/未經授權禁止複製)' . PHP_EOL, $metadata->description); - $this->assertEquals(['KanColle'], $metadata->tags); + $this->assertEquals(['KanColle', 'kochira'], $metadata->tags); $this->assertEquals('https://img.youtube.com/vi/pvA5Db082yo/maxresdefault.jpg', $metadata->image); if ($this->shouldUseMock()) { $this->assertSame($url, (string) $this->handler->getLastRequest()->getUri()); @@ -62,7 +62,7 @@ class IwaraResolverTest extends TestCase $metadata = $this->resolver->resolve($url); $this->assertEquals('鏡音りん18歳', $metadata->title); $this->assertEquals('投稿者: Tonjiru Lion' . PHP_EOL . '今回はあんまエロくないです。' . PHP_EOL, $metadata->description); - $this->assertEquals(['Vocaloid'], $metadata->tags); + $this->assertEquals(['Vocaloid', 'Tonjiru Lion'], $metadata->tags); $this->assertEquals('https://i.iwara.tv/sites/default/files/photos/jing_yin_rin18sui_a.png', $metadata->image); if ($this->shouldUseMock()) { $this->assertSame($url, (string) $this->handler->getLastRequest()->getUri()); From b7eafd881f77864d450216f636dec2431eb24a97 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Thu, 22 Aug 2019 07:28:28 +0900 Subject: [PATCH 4/8] =?UTF-8?q?description=E3=81=8C=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E3=81=97=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/IwaraResolver.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/MetadataResolver/IwaraResolver.php b/app/MetadataResolver/IwaraResolver.php index 736b3ca..a518d24 100644 --- a/app/MetadataResolver/IwaraResolver.php +++ b/app/MetadataResolver/IwaraResolver.php @@ -28,7 +28,10 @@ class IwaraResolver implements Resolver $descriptionElement = $crawler->filter('#video-player + div, .field-name-field-video-url + div, .field-name-field-images + div'); $title = $descriptionElement->filter('h1.title')->text(); $author = $descriptionElement->filter('.username')->text(); - $description = $descriptionElement->children('div')->eq(1)->text(); + $description = ''; + if ($descriptionElement->filter('.field-type-text-with-summary')->count()) { + $description = $descriptionElement->filter('.field-type-text-with-summary')->text(); + } $tags = $descriptionElement->filter('a[href^="/video-categories"], a[href^="/images"]')->extract('_text'); // 役に立たないタグを削除する $tags = array_values(array_diff($tags, ['Uncategorized', 'Other'])); From 4f23a9404b68a8cae07bb913a46fd34a787b963f Mon Sep 17 00:00:00 2001 From: eai04191 Date: Thu, 22 Aug 2019 07:47:42 +0900 Subject: [PATCH 5/8] =?UTF-8?q?=E5=90=8D=E5=89=8D=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/MetadataResolver/IwaraResolver.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/MetadataResolver/IwaraResolver.php b/app/MetadataResolver/IwaraResolver.php index a518d24..b876315 100644 --- a/app/MetadataResolver/IwaraResolver.php +++ b/app/MetadataResolver/IwaraResolver.php @@ -25,14 +25,14 @@ class IwaraResolver implements Resolver $html = (string) $res->getBody(); $crawler = new Crawler($html); - $descriptionElement = $crawler->filter('#video-player + div, .field-name-field-video-url + div, .field-name-field-images + div'); - $title = $descriptionElement->filter('h1.title')->text(); - $author = $descriptionElement->filter('.username')->text(); + $infoElements = $crawler->filter('#video-player + div, .field-name-field-video-url + div, .field-name-field-images + div'); + $title = $infoElements->filter('h1.title')->text(); + $author = $infoElements->filter('.username')->text(); $description = ''; - if ($descriptionElement->filter('.field-type-text-with-summary')->count()) { - $description = $descriptionElement->filter('.field-type-text-with-summary')->text(); + if ($infoElements->filter('.field-type-text-with-summary')->count()) { + $description = $infoElements->filter('.field-type-text-with-summary')->text(); } - $tags = $descriptionElement->filter('a[href^="/video-categories"], a[href^="/images"]')->extract('_text'); + $tags = $infoElements->filter('a[href^="/video-categories"], a[href^="/images"]')->extract('_text'); // 役に立たないタグを削除する $tags = array_values(array_diff($tags, ['Uncategorized', 'Other'])); array_push($tags, $author); From 8ef9a1f8f4301622d447ddee70aece8fff92a2a0 Mon Sep 17 00:00:00 2001 From: eai04191 Date: Wed, 28 Aug 2019 23:57:23 +0900 Subject: [PATCH 6/8] Update fixture --- tests/fixture/Iwara/images.html | 42 +++---- tests/fixture/Iwara/video.html | 196 +++++++++++++++---------------- tests/fixture/Iwara/youtube.html | 84 ++++++------- 3 files changed, 160 insertions(+), 162 deletions(-) diff --git a/tests/fixture/Iwara/images.html b/tests/fixture/Iwara/images.html index eb48004..4c81d00 100644 --- a/tests/fixture/Iwara/images.html +++ b/tests/fixture/Iwara/images.html @@ -86,7 +86,7 @@ window.jQuery || document.write(" @@ -128,7 +128,7 @@ jQuery.extend(Drupal.settings, {"basePath":"\/","pathPrefix":"","ajaxPageState": @@ -183,7 +183,7 @@ jQuery.extend(Drupal.settings, {"basePath":"\/","pathPrefix":"","ajaxPageState":

Cakeface【鈴谷、プリンツ】

@@ -194,7 +194,7 @@ jQuery.extend(Drupal.settings, {"basePath":"\/","pathPrefix":"","ajaxPageState": こっそり微修正…
Model:鈴谷&プリンツ つみだんご様 罪袋:BCD様
(いずれも改変)クレジット漏れゴメンナサイ。。。

-
- 5966 742,707
+ 6028 749,365
@@ -400,9 +400,7 @@ Model:鈴谷&プリンツ つみだんご様 罪袋:BCD様
+
-
ユーザー 超大电饭锅 の写真
- +
ユーザー sjenlin の写真
+
1日
@@ -1234,7 +1232,7 @@ It's a masterpiece!!

More from user

-
+
@@ -1242,14 +1240,48 @@ It's a masterpiece!!

+
+
+
+ + + + +
+
KotonohaYugi【Suzuya】
+
+ +
+
+
+
+
+
+ + + + +
+
BBペレ【mv】
+
+ +
+
+
+
+
+ 3234
+ 161.9k
摩耶とH
@@ -1258,32 +1290,32 @@ It's a masterpiece!!

-
+
+ 2173
+ 59.1k
-
KotonohaYugi【Suzuya】
+
IN your room【NO DANCE】マシュとH
-
+
+ 3003
+ 249.3k
HappyHalloween
@@ -1296,10 +1328,10 @@ It's a masterpiece!!

+ 2359
+ 232.5k
KotonohaYugi【Kongo】
@@ -1307,40 +1339,6 @@ It's a masterpiece!!

-
-
-
-
-
-
- - - - -
-
立ってる...【折岸みつ】
-
- -
-
-
-
-
-
- - - - -
-
BBペレ【mv】
-
- -
-
@@ -1357,7 +1355,7 @@ It's a masterpiece!!

More like this

-
Cakeface (※Futanari)
@@ -1403,10 +1401,10 @@ It's a masterpiece!!

+ 114
+ 7.4k
【MMD】 CAKEFACE
@@ -1437,10 +1435,10 @@ It's a masterpiece!!

+ 1362
+ 114.7k
プリンツ・ろーちゃんの黒丸いたずら一心不乱♡♡♡♡
@@ -1453,7 +1451,7 @@ It's a masterpiece!!

+ 240
@@ -1474,7 +1472,7 @@ It's a masterpiece!!

448
+ 37.2k
プリンツ 拘束中出しsex
@@ -1487,7 +1485,7 @@ It's a masterpiece!!

+ 201
@@ -1508,7 +1506,7 @@ It's a masterpiece!!

717
+ 30k
CakeFace!!! [R-18]
@@ -1542,7 +1540,7 @@ It's a masterpiece!!

191 + 35.5k
cakeface
@@ -1555,10 +1553,10 @@ It's a masterpiece!!

+ 582
+ 43.8k
Cakeface
@@ -1573,10 +1571,10 @@ It's a masterpiece!!

+ 158
+ 11.1k
CAKEFACE
@@ -1589,10 +1587,10 @@ It's a masterpiece!!

+ 146
+ 12.9k
cakeface
@@ -1623,10 +1621,10 @@ It's a masterpiece!!

+ 206
+ 13.1k
cakeface
@@ -1682,11 +1680,11 @@ It's a masterpiece!!

新しいフォーラムトピック

diff --git a/tests/fixture/Iwara/youtube.html b/tests/fixture/Iwara/youtube.html index e646ffb..e5aea12 100644 --- a/tests/fixture/Iwara/youtube.html +++ b/tests/fixture/Iwara/youtube.html @@ -86,7 +86,7 @@ window.jQuery || document.write("