diff --git a/lib/LANraragi/Plugin/Metadata/ComicInfo.pm b/lib/LANraragi/Plugin/Metadata/ComicInfo.pm index 585a2d0d5..464ef8cbc 100644 --- a/lib/LANraragi/Plugin/Metadata/ComicInfo.pm +++ b/lib/LANraragi/Plugin/Metadata/ComicInfo.pm @@ -60,6 +60,7 @@ sub get_tags { my $url; my $artist; my $lang; + my $title; my $result = Mojo::DOM->new->xml(1)->parse($stringxml)->at('Genre'); if ( defined $result ) { @@ -85,6 +86,10 @@ sub get_tags { if ( defined $result ) { $lang = $result->text; } + $result = Mojo::DOM->new->xml(1)->parse($stringxml)->at('Title'); + if ( defined $result ) { + $title = $result->text; + } #Delete local file unlink $filepath; @@ -105,7 +110,7 @@ sub get_tags { my $tags = join( ", ", @found_tags ); $logger->info("Sending the following tags to LRR: $tags"); - return ( tags => $tags ); + return ( tags => $tags, title => $title ); } sub try_add_tags { @@ -121,4 +126,4 @@ sub try_add_tags { return @found_tags; } -1; \ No newline at end of file +1; diff --git a/tests/LANraragi/Plugin/Metadata/ComicInfo.t b/tests/LANraragi/Plugin/Metadata/ComicInfo.t index 19a7267fe..4dcf27ef8 100644 --- a/tests/LANraragi/Plugin/Metadata/ComicInfo.t +++ b/tests/LANraragi/Plugin/Metadata/ComicInfo.t @@ -32,8 +32,9 @@ note("00 - [れむ] 夜伽妻 [DL版]"); # Since this is calling the sub directly and not in an object context, # we pass a dummy string as first parameter to replace the object. - my $returned_tags = LANraragi::Plugin::Metadata::ComicInfo::get_tags( "", \%dummyhash); + my %returned_tags = trap { LANraragi::Plugin::Metadata::ComicInfo::get_tags( "", \%dummyhash); }; + my $expected_title = "COMIC Anthurium 2021-09 [Digital]"; my $expected_group_tag = "group:Achumuchi, group:Ashita, group:Cool Kyou Shinja, group:Danimaru, group:Eba, group:Emuo, group:Fushoku, group:Inukami Inoji, group:Itaba Hiroshi, group:Kaiduka, group:Ken Sogen, group:Kosuke Haruhito, group:Maeda Momo, group:Miyano Kintarou, group:Rei, group:Sasahiro, group:Sekine Hajime, group:Ushinomiya, group:Yamamoto Ahiru, group:Yamamoto Zenzen"; my $expected_artist_tag = "artist:Achumuchi, artist:Ashita, artist:Cool Kyou Shinja, artist:Danimaru, artist:Eba, artist:Emuo, artist:Fushoku, artist:Inukami Inoji, artist:Itaba Hiroshi, artist:Kaiduka, artist:Ken Sogen, artist:Kosuke Haruhito, artist:Maeda Momo, artist:Miyano Kintarou, artist:Rei, artist:Sasahiro, artist:Sekine Hajime, artist:Ushinomiya, artist:Yamamoto Ahiru, artist:Yamamoto Zenzen"; my $expected_source_tag = "source:https://nhentai.net/g/369909/"; @@ -41,7 +42,8 @@ note("00 - [れむ] 夜伽妻 [DL版]"); my $expected_genre_tags = "Anal, Anthology, Beauty Mark, Big Breasts, Collar, Defloration, Eye-Covering Bang, Glasses, Gyaru, Huge Breasts, Incest, Inverted Nipples, Leotard, Long Tongue, Maid, Netorare, Pantyhose, Piercing, Ponytail, Robot, Schoolboy Uniform, Schoolgirl Uniform, Sister, Stockings, Sweating, Tomboy"; my @tag_array = ($expected_group_tag, $expected_artist_tag, $expected_source_tag, $expected_lang_tag, $expected_genre_tags); my $expected_tags = join( ", ", @tag_array ); - is( $returned_tags, $expected_tags, "correct tags" ); + is( $returned_tags{tags}, $expected_tags, "correct tags" ); + is( $returned_tags{title}, $expected_title, "correct title" ); } note("01 - 夜伽妻"); @@ -58,8 +60,9 @@ note("01 - 夜伽妻"); # Since this is calling the sub directly and not in an object context, # we pass a dummy string as first parameter to replace the object. - my $returned_tags = LANraragi::Plugin::Metadata::ComicInfo::get_tags( "", \%dummyhash); + my %returned_tags = trap { LANraragi::Plugin::Metadata::ComicInfo::get_tags( "", \%dummyhash); }; + my $expected_title = "[れむ] 夜伽妻 [DL版]"; my $expected_group_tag = "group:Remu"; my $expected_artist_tag = "artist:Remu"; my $expected_source_tag = "source:https://e-hentai.org/g/2470908/3dd0f5801e/"; @@ -67,7 +70,8 @@ note("01 - 夜伽妻"); my $expected_genre_tags = "Ahegao, Bbw, Big Areolae, Big Ass, Big Breasts, Big Nipples, Big Penis, Blowjob, Bondage, Cheating, Crotch Tattoo, Dark Skin, Facial Hair, Filming, Glasses, Glasses, Gyaru, Hairy, Huge Breasts, Impregnation, Maid, Milf, Nakadashi, Netorare, Oil, Paizuri, Pregnant, Prostitution, Schoolgirl Uniform, Swinging, Tall Girl, Tankoubon, Very Long Hair, Voyeurism, Widow, X-Ray"; my @tag_array = ($expected_group_tag, $expected_artist_tag, $expected_source_tag, $expected_lang_tag, $expected_genre_tags); my $expected_tags = join( ", ", @tag_array ); - is( $returned_tags, $expected_tags, "correct tags" ); + is( $returned_tags{tags}, $expected_tags, "correct tags" ); + is( $returned_tags{title}, $expected_title, "correct title" ); } note("02 - よつばと! 第01巻"); @@ -84,15 +88,17 @@ note("02 - よつばと! 第01巻"); # Since this is calling the sub directly and not in an object context, # we pass a dummy string as first parameter to replace the object. - my $returned_tags = LANraragi::Plugin::Metadata::ComicInfo::get_tags( "", \%dummyhash); + my %returned_tags = trap { LANraragi::Plugin::Metadata::ComicInfo::get_tags( "", \%dummyhash); }; + my $expected_title = "よつばと! 第01巻"; my $expected_group_tag = "group:あずまきよひこ"; my $expected_artist_tag = "artist:あずまきよひこ"; my $expected_lang_tag = "language:ja"; my $expected_genre_tags = "Comedy, Shounen, Slice of Life"; my @tag_array = ($expected_group_tag, $expected_artist_tag, $expected_lang_tag, $expected_genre_tags); my $expected_tags = join( ", ", @tag_array ); - is( $returned_tags, $expected_tags, "correct tags" ); + is( $returned_tags{tags}, $expected_tags, "correct tags" ); + is( $returned_tags{title}, $expected_title, "correct title" ); } note("03 - 異種姦オーガズム"); @@ -109,15 +115,17 @@ note("03 - 異種姦オーガズム"); # Since this is calling the sub directly and not in an object context, # we pass a dummy string as first parameter to replace the object. - my $returned_tags = LANraragi::Plugin::Metadata::ComicInfo::get_tags( "", \%dummyhash); + my %returned_tags = trap { LANraragi::Plugin::Metadata::ComicInfo::get_tags( "", \%dummyhash); }; + my $expected_title = "異種姦オーガズム"; my $expected_group_tag = "group:7zu7"; my $expected_lang_tag = "language:zh"; my $expected_genre_tags = "translated, artist:7zu7, male:monster, Manga, Uploaded"; my @tag_array = ($expected_group_tag, $expected_lang_tag, $expected_genre_tags); my $expected_tags = join( ", ", @tag_array ); - is( $returned_tags, $expected_tags, "correct tags" ); + is( $returned_tags{tags}, $expected_tags, "correct tags" ); + is( $returned_tags{title}, $expected_title, "correct title" ); } -done_testing(); \ No newline at end of file +done_testing();