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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Processing video, please check back in a while
+
+
+
+
+
+
+
+
+
+
+
+
Cakeface【鈴谷、プリンツ】
+ 作成者:
kuro@vov 作成日:2017-05-30 12:01
+
+
+
Thank you for watching!いつもありがとうございます
+こっそり微修正…
+Model:鈴谷&プリンツ つみだんご様 罪袋:BCD様
+(いずれも改変)クレジット漏れゴメンナサイ。。。
+
+ 5966 742,707
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
18歳以上!
+
一般的な作品に加えて性描写など
+18歳未満の方は閲覧できない情報が含まれています。
+
+
+
+
+
+
+
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
むちむち天龍ちゃんで君色に染まる
+ 作成者:
kochira 作成日:2017-08-16 08:14
+
+
+
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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様
(いずれも改変)クレジット漏れゴメンナサイ。。。
-
+
@@ -202,7 +202,7 @@ Model:鈴谷&プリンツ つみだんご様 罪袋:BCD様
- 5966 742,707
+ 6028 749,365
@@ -1453,7 +1451,7 @@ It's a masterpiece!!
20.1k
@@ -1474,7 +1472,7 @@ It's a masterpiece!!
448
- 37k
+ 37.2k
@@ -1487,7 +1485,7 @@ It's a masterpiece!!
11.1k
@@ -1508,7 +1506,7 @@ It's a masterpiece!!
717
- 29.9k
+ 30k
@@ -1542,7 +1540,7 @@ It's a masterpiece!!
191
- 35.4k
+ 35.5k
@@ -1555,10 +1553,10 @@ It's a masterpiece!!
@@ -1573,10 +1571,10 @@ It's a masterpiece!!
@@ -1589,10 +1587,10 @@ It's a masterpiece!!
@@ -1623,10 +1621,10 @@ It's a masterpiece!!
@@ -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("
+ コメント数 6
+ + +良いカスタムモデルですね
++ぶっちゃけ裸よりエロいです(*´ω`)
可愛いと思います!
+これくらいの微エロも捗りますね
+これはけしからん18歳
+That is Nice!
+Lovely! I wanna make her videos!! plz
+