Skip to content

Commit

Permalink
LANraragi Release 0.8.1
Browse files Browse the repository at this point in the history
Merge pull request #524 from Difegue/dev
  • Loading branch information
Difegue authored Oct 14, 2021
2 parents 75cdf9c + c6b10ec commit c4fcc49
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 94 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ Open source server for archival of comics/manga, running on Mojolicious + Redis.

#### [📄 Documentation](https://sugoi.gitbook.io/lanraragi/) | [⏬ Download](https://github.com/Difegue/LANraragi/releases/latest) | [🎞 Demo](https://lrr.tvc-16.science) | [🐱‍👓 Windows Nightlies](https://nightly.link/Difegue/LANraragi/workflows/push-continous-delivery/dev) | [💵 Sponsor Development](https://ko-fi.com/T6T2UP5N)

## The 2021 User Survey is live!
## The 2021 User Survey results have landed!

Suggest new features and give feedback without having to create a GitHub account!
Check [here](https://tvc-16.science/lrr-survey-3.html) for more info.
Check [here](https://tvc-16.science/lrr-survey-3-results.html) for more info.

## Screenshots

Expand Down
7 changes: 6 additions & 1 deletion lib/LANraragi/Controller/Api/Archive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,12 @@ sub serve_metadata {

my $arcdata = LANraragi::Utils::Database::build_archive_JSON( $redis, $id );
$redis->quit;
$self->render( json => $arcdata );

if ($arcdata) {
$self->render( json => $arcdata );
} else {
render_api_response( $self, "metadata", "This ID doesn't exist on the server." );
}
}

# Find which categories this ID is saved in.
Expand Down
2 changes: 1 addition & 1 deletion lib/LANraragi/Model/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ sub do_search {
} else {
next;
}
my $id = @ids[$i];
my $id = $ids[$i];

my ( $tags, $title, $file, $isnew ) = @hash{qw(tags title file isnew)};

Expand Down
3 changes: 1 addition & 2 deletions lib/LANraragi/Model/Stats.pm
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ sub build_stat_hashes {
# If the tag is a source: tag, add it to the URL index
if ( $t =~ /source:(.*)/i ) {
my $url = $1;
$logger->debug("Adding $url as an URL for $id");
trim_url($url);
$logger->debug("Trimmed: $url");
$logger->debug("Adding $url as an URL for $id");
$redistx->hset( "LRR_URLMAP", $url, $id ); # No need to encode the value, as URLs are already encoded by design
}

Expand Down
22 changes: 6 additions & 16 deletions lib/LANraragi/Plugin/Metadata/Chaika.pm
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ sub plugin_info {
type => "metadata",
namespace => "trabant",
author => "Difegue",
version => "2.1.1",
description => "Searches chaika.moe for tags matching your archive.",
version => "2.2",
description => "Searches chaika.moe for tags matching your archive. This will try to use the thumbnail first, and fallback to a default text search.",
icon =>
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA\nB3RJTUUH4wYCFQocjU4r+QAAAB1pVFh0Q29tbWVudAAAAAAAQ3JlYXRlZCB3aXRoIEdJTVBkLmUH\nAAAEZElEQVQ4y42T3WtTdxzGn/M7J+fk5SRpTk7TxMZkXU84tTbVNrUT3YxO7HA4pdtQZDe7cgx2\ns8vBRvEPsOwFYTDYGJUpbDI2wV04cGXCGFLonIu1L2ptmtrmxeb1JDkvv121ZKVze66f74eH7/f5\nMmjRwMCAwrt4/9KDpflMJpPHvyiR2DPcJklJ3TRDDa0xk36cvrm8vDwHAAwAqKrqjjwXecPG205w\nHBuqa9rk77/d/qJYLD7cCht5deQIIczbgiAEKLVAKXWUiqVV06Tf35q8dYVJJBJem2A7Kwi2nQzD\nZig1CG93+PO5/KN6tf5NKpVqbsBUVVVFUUxwHJc1TXNBoxojS7IbhrnLMMx9pVJlBqFQKBKPxwcB\nkJYgjKIo3QCE1nSKoghbfJuKRqN2RVXexMaQzWaLezyeEUEQDjscjk78PxFFUYRkMsltJgGA3t7e\nyMLCwie6rr8iCILVbDbvMgwzYRjGxe0o4XC4s1AoHPP5fMP5/NNOyzLKAO6Ew+HrDADBbre/Ryk9\nnzx81FXJNlEpVpF+OqtpWu2MpmnXWmH9/f2umZmZi4cOHXnLbILLzOchhz1YerJAs9m1GwRAg2GY\nh7GYah488BJYzYW+2BD61AFBlmX/1nSNRqN9//792ujoaIPVRMjOKHoie3DytVGmp2fXCAEAjuMm\nu7u7Umosho6gjL/u/QHeEgvJZHJ2K/D+/fuL4+PjXyvPd5ldkShy1UXcmb4DnjgQj/fd5gDA6/XS\nYCAwTwh9oT3QzrS1+VDVi+vd3Tsy26yQVoFF3dAXJVmK96p9EJ0iLNOwKKU3CQCk0+lSOpP5WLDz\nF9Q9kZqyO0SloOs6gMfbHSU5NLRiUOuax2/HyZPHEOsLw2SbP83eu/fLxrkNp9P554XxCzVa16MC\n7+BPnTk9cfmH74KJE8nmga7Xy5JkZ8VKifGIHpoBb1VX8hNTd3/t/7lQ3OeXfFPvf/jBRw8ezD/a\n7M/aWq91cGgnJaZ2VcgSdnV1XRNNd3vAoBVVYusmnEQS65hfgSG6c+zy3Kre7nF/KrukcMW0Zg8O\nD08DoJutDxxOEb5IPUymwrq8ft1gLKfkFojkkRxemERCAQUACPFWRazYLJcrFGwQhyufbQQ7rFpy\nLMkCwGZC34qPIuwp+XPOjBFwazQ/txrdFS2GGS/Xuj+pUKLGk1Kjvlded3s72lyGW+PLbGVcmrAA\ngN0wTk1NWYODg9XOKltGtpazi5GigzroUnHN5nUHG1ylRsG7rDXHmnEpu4CeEtEKkqNc6QqlLc/M\n8uT5lLH5eq0aGxsju1O7GQB498a5s/0x9dRALPaQEDZnYwnhWJtMCCNrjeb0UP34Z6e/PW22zjPP\n+vwXBwfPvbw38XnXjk7GsiwKAIQQhjAMMrlsam45d+zLH6/8o6vkWcBcrXbVKQhf6bpucCwLjmUB\nSmmhXC419eblrbD/TAgAkUjE987xE0c7ZDmk66ajUCnq+cL63fErl25s5/8baQPaWLhx6goAAAAA\nSUVORK5CYII=",
parameters => [ { type => "bool", desc => "Save archive title" } ],
Expand All @@ -47,10 +47,12 @@ sub get_tags {
} else {

# Try SHA-1 reverse search first
$logger->info("Using thumbnail hash " . $lrr_info->{thumbnail_hash});
( $newtags, $newtitle ) = tags_from_sha1( $lrr_info->{thumbnail_hash} );

# Try search if it fails
# Try text search if it fails
if ( $newtags eq "" ) {
$logger->info("No results, falling back to text search.");
( $newtags, $newtitle ) = search_for_archive( $lrr_info->{archive_title}, $lrr_info->{existing_tags} );
}
}
Expand Down Expand Up @@ -127,19 +129,7 @@ sub tags_from_sha1 {
# Said JSON is an array containing multiple archive objects.
# We just take the first one.
my $json_by_sha1 = get_json_from_chaika( 'sha1', $sha1 );
my $chaika_id = $json_by_sha1->[0]->{"id"};
$logger->debug("Gallery ID detected($chaika_id), trying to switch to it.");

# Switch to gallery tags if there are any.
# Occasionally archives won't have a matching gallery despite the ID being there. (huh)
my $json = get_json_from_chaika( 'gallery' , $chaika_id);

if ( !$json->{"tags"} ) {
$logger->debug("Gallery doesn't actually have tags! Switching back to Archive.");
$json = $json_by_sha1->[0];
}

return parse_chaika_json( $json );
return parse_chaika_json( $json_by_sha1->[0] );
}

# Calls chaika's API
Expand Down
10 changes: 6 additions & 4 deletions lib/LANraragi/Plugin/Metadata/Fakku.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sub plugin_info {
namespace => "fakkumetadata",
login_from => "fakkulogin",
author => "Difegue, Nodja",
version => "0.7",
version => "0.8",
description =>
"Searches FAKKU for tags matching your archive. If you have an account, don't forget to enter the matching cookie in the login plugin to be able to access controversial content.",
icon =>
Expand Down Expand Up @@ -113,8 +113,10 @@ sub get_search_result_dom {

my $logger = get_plugin_logger();

#Strip away characters that break search
$title =~ s/-|'|~|!|/ /g;
# Strip away characters that break search
# Note: Those characters work fine, but the F! search backend sometimes fails to match you anyway.
# Removing them doesn't seem to really improve the situation. :/ The autosuggest API would work better but then again, CF issues
$title =~ s/-|'|~|!|//g;

# Visit the base host once to set cloudflare cookies and jank
$ua->max_redirects(5)->get($fakku_host);
Expand Down Expand Up @@ -183,7 +185,7 @@ sub get_tags_from_fakku {

my $namespace = $row[0]->text;

$logger->debug("testaroni: $row[1]");
$logger->debug("Evaluating row: $row[1]");
my $value =
( $row[1]->at('a') )
? $row[1]->at('a')->text
Expand Down
2 changes: 1 addition & 1 deletion lib/LANraragi/Plugin/Metadata/nHentai.pm
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ sub get_tags {
my $galleryID = "";

# Quick regex to get the nh gallery id from the provided url.
if ( $lrr_info->{oneshot_param} =~ /.*\/g\/([0-9]*)\/.*/ ) {
if ( $lrr_info->{oneshot_param} =~ /.*\/g\/([0-9]+).*/ ) {
$galleryID = $1;
} else {

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lanraragi",
"version": "0.8.0",
"version_name": "Black Tie White Noise",
"version": "0.8.1",
"version_name": "Black Tie White Noise (Here Come Da Jazz Mix)",
"description": "I'm under Japanese influence and my honor's at stake!",
"scripts": {
"test": "prove -r -l -v tests/",
Expand Down
1 change: 1 addition & 0 deletions public/css/config.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ input[type='checkbox'] {
font-size:20px;
cursor:pointer;
margin-left: 0px;
color: inherit;
}

input[type='checkbox']::before {
Expand Down
40 changes: 6 additions & 34 deletions tests/LANraragi/Plugin/Metadata/Chaika.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@ my $cwd = getcwd();
my $SAMPLES = "$cwd/tests/samples";
require "$cwd/tests/mocks.pl";

my @tags_list_from_gallery = (
my @tags_list= (
'female:sole female', 'male:sole male', 'artist:kemuri haku', 'full censorship',
'male:shotacon', 'female:defloration', 'female:nakadashi', 'female:big breasts',
'language:translated', 'language:english'
);

my @tags_list_from_sha1 = (
'ahegao', 'artist:ao banana', 'blowjob', 'busty', 'creampie', 'dark skin', 'eyebrows',
'heart pupils', 'hentai', 'language:english', 'magazine:comic shitsurakuten 2016-04',
'muscles', 'parody:original work', 'publisher:fakku', 'swimsuit', 'tanlines', 'uncensored',
'unlimited', 'x-ray'
);

use_ok('LANraragi::Plugin::Metadata::Chaika');

note ( 'testing retrieving tags by ID ...' );
Expand All @@ -40,13 +33,13 @@ note ( 'testing retrieving tags by ID ...' );
my ( $tags, $title ) = LANraragi::Plugin::Metadata::Chaika::tags_from_chaika_id( "my-type", 123 );

is($title, $json->{title}, 'gallery title');
cmp_bag( [ split( ', ', $tags ) ] , \@tags_list_from_gallery, 'gallery tag list');
cmp_bag( [ split( ', ', $tags ) ] , \@tags_list, 'gallery tag list');
}

note ( 'testing retrieving tags by SHA1 when "gallery" has "tags" ...' );
note ( 'testing retrieving tags by SHA1 ...' );

{
my $json_by_sha1 = [ { 'id' => '666' } ];
my $json_by_sha1 = decode_json( Mojo::File->new("$SAMPLES/chaika/002_sha1_response.json")->slurp );
my $json = decode_json( Mojo::File->new("$SAMPLES/chaika/001_gid_27240.json")->slurp );
my @type_params = ();

Expand All @@ -61,29 +54,8 @@ note ( 'testing retrieving tags by SHA1 when "gallery" has "tags" ...' );
my ( $tags, $title ) = LANraragi::Plugin::Metadata::Chaika::tags_from_sha1( "my-hash" );

is($title, $json->{title}, 'gallery title');
cmp_bag( [ split( ', ', $tags ) ] , \@tags_list_from_gallery, 'gallery tag list');
cmp_deeply( \@type_params, [ 'sha1', 'gallery' ], 'API call sequence');
}

note ( 'testing retrieving tags by SHA1 when "gallery" has no "tags" ...' );

{
my $json = decode_json( Mojo::File->new("$SAMPLES/chaika/002_sha1_response.json")->slurp );
my @type_params = ();

no warnings 'once', 'redefine';
local *LANraragi::Plugin::Metadata::Chaika::get_plugin_logger = sub { return get_logger_mock(); };
local *LANraragi::Plugin::Metadata::Chaika::get_json_from_chaika = sub {
my ( $type, $value ) = @_;
push( @type_params, $type );
return ( $type eq 'sha1' ) ? $json : {};
};

my ( $tags, $title ) = LANraragi::Plugin::Metadata::Chaika::tags_from_sha1( "my-hash" );

is($title, $json->[0]->{title}, 'gallery title');
cmp_bag( [ split( ', ', $tags ) ] , \@tags_list_from_sha1, 'gallery tag list');
cmp_deeply( \@type_params, [ 'sha1', 'gallery' ], 'API call sequence');
cmp_bag( [ split( ', ', $tags ) ] , \@tags_list, 'gallery tag list');
cmp_deeply( \@type_params, [ 'sha1' ], 'API call sequence');
}

done_testing();
48 changes: 19 additions & 29 deletions tests/samples/chaika/002_sha1_response.json
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
[{
"category": "Manga",
"download": "/archive/21493/download/",
"download": "/archive/27240/download/",
"expunged": false,
"filecount": 20,
"filesize": 12965929,
"fjord": false,
"gallery": 15195,
"id": 21493,
"posted": 1459639197,
"rating": 0.0,
"filecount": 19,
"filesize": 63418139,
"fjord": true,
"gallery": 23532,
"posted": 1521353952,
"rating": 4.45,
"tags": [
"busty",
"unlimited",
"parody:original_work",
"heart_pupils",
"magazine:comic_shitsurakuten_2016-04",
"publisher:fakku",
"blowjob",
"creampie",
"eyebrows",
"muscles",
"swimsuit",
"tanlines",
"dark_skin",
"ahegao",
"x-ray",
"hentai",
"artist:ao_banana",
"uncensored",
"female:sole_female",
"male:sole_male",
"artist:kemuri_haku",
"full_censorship",
"male:shotacon",
"female:defloration",
"female:nakadashi",
"female:big_breasts",
"language:translated",
"language:english"
],
"title": "Naughty Bath Matsuri-chan",
"title_jpn": "",
"uploader": "5 a.m."
"title": "[Kemuri Haku] Zettai Seikou Keikaku | Absolute Intercourse Plan (COMIC Shitsurakuten 2016-03) [English] [Redlantern]",
"title_jpn": "[煙ハク] 絶対セイコウ計画 (COMIC 失楽天 2016年3月号) [英訳]",
"uploader": "dankestdungeon"
}]

0 comments on commit c4fcc49

Please sign in to comment.