Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try fetching data from info.yaml #842

Merged
merged 1 commit into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/LANraragi/Plugin/Metadata/Ksk.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ sub get_tags {
my $path_in_archive = is_file_in_archive( $file, "koushoku.yaml" );

if ( !$path_in_archive ) {
return ( error => "No koushoku.yaml file found in archive" );
$path_in_archive = is_file_in_archive( $file, "info.yaml" );
}

if ( !$path_in_archive ) {
return ( error => "No KSK metadata file found in archive" );
}

my $filepath = extract_file_from_archive( $file, $path_in_archive );
Expand Down
16 changes: 16 additions & 0 deletions tests/LANraragi/Plugin/Metadata/Ksk.t
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,20 @@ note("test fetching title, assuming language");
is( $ko_tags{tags}, $expected_tags, "Language is present" );
}

note("test support for info.yaml");
{
my ( $fh, $filename ) = tempfile();
cp( $SAMPLES . "/ksk/fake.yaml", $fh );

no warnings 'once', 'redefine';
local *LANraragi::Plugin::Metadata::Ksk::get_plugin_logger = sub { return get_logger_mock(); };
local *LANraragi::Plugin::Metadata::Ksk::extract_file_from_archive = sub { $filename };
local *LANraragi::Plugin::Metadata::Ksk::is_file_in_archive = sub { my $fn = $_[1]; return $fn eq "info.yaml"; };

my %dummyhash = ( file_path => "test" );

my %ko_tags = LANraragi::Plugin::Metadata::Ksk::get_tags( "", \%dummyhash, 1, 1 );
is( $ko_tags{title}, "My Immortal", "Loads data from info.yaml" );
}

done_testing();