Skip to content

Commit

Permalink
LANraragi Release 0.9.2
Browse files Browse the repository at this point in the history
Merge pull request #1031 from Difegue/dev
  • Loading branch information
Difegue authored Jul 25, 2024
2 parents fbd98f4 + 591b3b6 commit 7bdc218
Show file tree
Hide file tree
Showing 45 changed files with 438 additions and 139 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/push-continous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ jobs:
key: ${{ runner.os }}-docker-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-buildx-
- name: Build x86/ARMv7 images
- name: Build ARMv6/ARMv7 images
run: |
apt-get update && apt-get upgrade
docker buildx build \
--platform linux/arm/v6,linux/arm/v7 \
--output "type=image,push=false" \
Expand Down Expand Up @@ -75,7 +76,7 @@ jobs:
docker create --name rootfs difegue/lanraragi
docker export --output=package.tar rootfs
- name: Upload rootfs
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: package
path: package.tar
Expand All @@ -91,7 +92,7 @@ jobs:
docker create --name rootfs difegue/lanraragi
docker export --output=package.tar rootfs
- name: Upload rootfs
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: package-legacy
path: package.tar
Expand All @@ -103,11 +104,11 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Download package
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4
with:
name: package
- name: Download package
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4
with:
name: package-legacy
- name: Build MSI Installer
Expand All @@ -126,12 +127,12 @@ jobs:
choco install nuget.commandline
./tools/build/windows/build.ps1
- name: Upload Installer
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: LANraragi.msi
path: ./tools/build/windows/Karen/LRR_WSL2.msi
- name: Upload Installer
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: LANraragi_legacy.msi
path: ./tools/build/windows/Karen/LRR_WSL1.msi
12 changes: 6 additions & 6 deletions .github/workflows/release-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
docker create --name rootfs difegue/lanraragi
docker export --output=package.tar rootfs
- name: Upload rootfs
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: package
path: package.tar
Expand All @@ -27,7 +27,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Download package
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4
with:
name: package
- name: Build MSI Installer
Expand All @@ -46,25 +46,25 @@ jobs:
choco install nuget.commandline
./tools/build/windows/build.ps1
- name: Upload Installer
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: wsl
name: LANraragi.msi
path: ./tools/build/windows/Karen/LRR_WSL2.msi
uploadWSLRelease:
name: Add Windows Installer to release
needs: buildReleaseWSL
runs-on: ubuntu-latest
steps:
- name: Download package
uses: actions/download-artifact@v1
uses: actions/download-artifact@v4
with:
name: wsl
- name: Upload Installer to release
uses: JasonEtco/upload-to-release@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: wsl/LANraragi.msi application/octet-stream
args: wsl/LRR_WSL2.msi application/octet-stream
- uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
Expand Down
7 changes: 4 additions & 3 deletions lib/LANraragi/Controller/Batch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Encode;
use Mojo::JSON qw(decode_json);

use LANraragi::Utils::Generic qw(generate_themes_header);
use LANraragi::Utils::Tags qw(rewrite_tags split_tags_to_array restore_CRLF);
use LANraragi::Utils::Tags qw(rewrite_tags build_tag_replace_hash split_tags_to_array restore_CRLF);
use LANraragi::Utils::Database qw(redis_decode get_computed_tagrules set_tags set_title set_summary set_isnew invalidate_cache);
use LANraragi::Utils::Plugins qw(get_plugins get_plugin get_plugin_parameters);
use LANraragi::Utils::Logging qw(get_logger);
Expand Down Expand Up @@ -48,6 +48,8 @@ sub socket {
# Increase inactivity timeout for connection a bit to account for clientside timeouts
$self->inactivity_timeout(80);

my @rules = get_computed_tagrules();
my ( $rules, $hash_replace_rules ) = build_tag_replace_hash( \@rules );
$self->on(
message => sub {
my ( $self, $msg ) = @_;
Expand Down Expand Up @@ -132,8 +134,7 @@ sub socket {
$tags = redis_decode($tags);

my @tagarray = split_tags_to_array($tags);
my @rules = get_computed_tagrules();
@tagarray = rewrite_tags( \@tagarray, \@rules );
@tagarray = rewrite_tags(\@tagarray, $rules, $hash_replace_rules);

# Merge array with commas
my $newtags = join( ', ', @tagarray );
Expand Down
6 changes: 5 additions & 1 deletion lib/LANraragi/Controller/Plugins.pm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,11 @@ sub process_upload {
return;
}

my $dir = getcwd() . ("/lib/LANraragi/Plugin/$plugintype/");
my $dir = getcwd() . ("/lib/LANraragi/Plugin/Sideloaded/");
unless ( -e $dir ) {
mkdir $dir;
}

my $output_file = $dir . $filename;

$logger->info("Uploading new plugin $filename to $output_file ...");
Expand Down
2 changes: 1 addition & 1 deletion lib/LANraragi/Model/Backup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use Mojo::JSON qw(decode_json encode_json);
use LANraragi::Model::Category;
use LANraragi::Utils::Database;
use LANraragi::Utils::String qw(trim_CRLF);
use LANraragi::Utils::Database qw(redis_encode redis_decode invalidate_cache set_title set_tags);
use LANraragi::Utils::Database qw(redis_encode redis_decode invalidate_cache set_title set_tags set_summary);
use LANraragi::Utils::Logging qw(get_logger);

#build_backup_JSON()
Expand Down
6 changes: 6 additions & 0 deletions lib/LANraragi/Model/Stats.pm
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ sub build_tag_stats {
# detect the : symbol and only use what's after it
my $ns = "";
my $t = redis_decode($_);

# Ignore tags that start with "source:" or "date_added:"
if ($t =~ /^source:/ || $t =~ /^date_added:/) {
next;
}

if ( $t =~ /([^:]*):(.*)/ ) { $ns = $1; $t = $2; }

if ( $_ ne "" ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/LANraragi/Plugin/Metadata/EHentai.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ sub get_tags {
$gID = $1;
$gToken = $2;
$logger->debug("Skipping search and using gallery $gID / $gToken from oneshot args");
} elsif ( $lrr_info->{existing_tags} =~ /.*source:\s*e(?:x|-)hentai\.org\/g\/([0-9]*)\/([0-z]*)\/*.*/gi ) {
} elsif ( $lrr_info->{existing_tags} =~ /.*source:\s*(?:https?:\/\/)?e(?:x|-)hentai\.org\/g\/([0-9]*)\/([0-z]*)\/*.*/gi ) {
$gID = $1;
$gToken = $2;
$hasSrc = 1;
Expand Down
63 changes: 51 additions & 12 deletions lib/LANraragi/Plugin/Metadata/Fakku.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ sub plugin_info {
namespace => "fakkumetadata",
login_from => "fakkulogin",
author => "Difegue, Nodja, Nixis198",
version => "0.94",
version => "0.97",
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. <br/><br/>
<i class='fa fa-exclamation-circle'></i> <b>This plugin can and will return invalid results depending on what you're searching for!</b> <br/>The FAKKU search API isn't very precise and I recommend you use the Chaika.moe plugin when possible.",
icon =>
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAACZSURBVDhPlY+xDYQwDEWvZgRGYA22Y4frqJDSZhFugiuuo4cqPGT0iTjAYL3C+fGzktc3hEcsQvJq6HtjE2Jdv4viH4a4pWnL8q4A6g+ET9P8YhS2/kqwIZXWnwqChDxPfCFfD76wOzJ2IOR/0DSwnuRKYAKUW3gq2OsJTYM0jr7QVRVwlabJEaw3ARYBcmFXeomxphIeEMIMmh3lOLQR+QQAAAAASUVORK5CYII=",
parameters => [],
oneshot_arg => "FAKKU Gallery URL (Will attach tags matching this exact gallery to your archive)"
oneshot_arg => "FAKKU Gallery URL (Will attach tags matching this exact gallery to your archive)",
parameters => [ { type => "bool", desc => "Add 'Source' tag" } ]
);

}
Expand All @@ -41,8 +41,9 @@ sub plugin_info {
sub get_tags {

shift;
my $lrr_info = shift; # Global info hash
my $ua = $lrr_info->{user_agent};
my $lrr_info = shift; # Global info hash
my $ua = $lrr_info->{user_agent};
my ($add_source) = @_;

my $logger = get_plugin_logger();

Expand Down Expand Up @@ -77,13 +78,27 @@ sub get_tags {

my $fakku_URL = "";

# Looks for the "source:" in the existing tags.
my @oldTags = split( ',', $lrr_info->{existing_tags} );
my $pattern = qr/^source:(.+)$/;

foreach my $oldtag (@oldTags) {
if ( $oldtag =~ $pattern ) {
my $foundURL = $1;
if ( $foundURL =~ /fakku\.net/ ) { #Makes sure the found url is a fakku.net url.
$fakku_URL = $foundURL;
}
}
}

# If the user specified a oneshot argument, use it as-is.
# We could stand to pre-check it to see if it really is a FAKKU URL but meh
if ( $lrr_info->{oneshot_param} ) {
$fakku_URL = $lrr_info->{oneshot_param};
} else {
}
if ( $fakku_URL eq "" ) {

# Search for a FAKKU URL if the user didn't specify one
# Search for a FAKKU URL if the user didn't specify one or none found in the tags.
$fakku_URL = search_for_fakku_url( $lrr_info->{archive_title}, $ua );
}

Expand All @@ -95,8 +110,8 @@ sub get_tags {
return ( error => "No matching FAKKU Gallery Found!" );
}

my ( $newtags, $newtitle );
eval { ( $newtags, $newtitle ) = get_tags_from_fakku( $fakku_URL, $ua ); };
my ( $newtags, $newtitle, $newSummary );
eval { ( $newtags, $newtitle, $newSummary ) = get_tags_from_fakku( $fakku_URL, $ua, $add_source ); };

if ($@) {
return ( error => $@ );
Expand All @@ -105,7 +120,7 @@ sub get_tags {
$logger->info("Sending the following tags to LRR: $newtags");

#Return a hash containing the new metadata - it will be integrated in LRR.
return ( tags => $newtags, title => $newtitle );
return ( tags => $newtags, title => $newtitle, summary => $newSummary );
}

######
Expand Down Expand Up @@ -192,7 +207,7 @@ sub get_dom_from_fakku {
# Parses a FAKKU URL for tags.
sub get_tags_from_fakku {

my ( $url, $ua ) = @_;
my ( $url, $ua, $add_url ) = @_;

my $logger = get_plugin_logger();

Expand All @@ -211,6 +226,24 @@ sub get_tags_from_fakku {

my @tags = ();

# Finds the DIV for the Summary.
my $summ_selector =
'.table-cell.w-full.align-top.text-left.space-y-2.leading-relaxed.link\:text-blue-700.dark\:link\:text-white';
my $summ_div = $dom->at($summ_selector);
my $summary;

# If the Summary DIV doesn't exist, return a blank string.
if ( defined $summ_div ) {
$summary = $summ_div->all_text;
} else {
$summary = "";
}

# If no FAKKU description exists, just keep it blank.
if ( $summary eq "No description has been written." ) {
$summary = "";
}

# We can grab some namespaced tags from the first few div.
my @namespaces = $metadata_parent->children('div')->each;

Expand Down Expand Up @@ -262,7 +295,13 @@ sub get_tags_from_fakku {
}
}

return ( join( ', ', @tags ), $title );
# Adds the source tag is enabled.
if ($add_url) {
$url =~ s{^https://www\.}{}i;
push( @tags, "source:" . $url );
}

return ( join( ', ', @tags ), $title, $summary );

}

Expand Down
50 changes: 37 additions & 13 deletions lib/LANraragi/Plugin/Metadata/Ksk.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use YAML::PP qw(LoadFile);
sub plugin_info {

return (
name => "Koushoku.yaml",
name => "Koushoku/Koharu.yaml",
type => "metadata",
namespace => "kskyamlmeta",
author => "siliconfeces, Nixis198",
version => "0.003",
version => "0.004",
description => "Collects metadata embedded into your archives as koushoku.yaml/info.yaml files.",
icon =>
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAANkSURBVDhPJZJpU5NXGIbf/9Ev0g+MM7Udp9WWDsVOsRYQKEVZQ4BsZnt9sy9shgShBbTYaTVCKY1B1pBEQ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DhPxYUixj0Cgg3AAAAAElFTkSuQmCC",
Expand Down Expand Up @@ -75,18 +75,27 @@ sub tags_from_ksk_yaml {
my $url = $hash->{"URL"};
my $released = $hash->{"Released"};

foreach my $tag (@$tags) {
push( @found_tags, $tag );
}
foreach my $tag (@$artists) {
push( @found_tags, "artist:" . $tag );
}
foreach my $tag (@$parody) {
push( @found_tags, "series:" . $tag );
}
foreach my $tag (@$magazine) {
push( @found_tags, "magazine:" . $tag );
handle_tag_yaml( "", $tags, \@found_tags );
handle_tag_yaml( "artist:", $artists, \@found_tags );
handle_tag_yaml( "series:", $parody, \@found_tags );
handle_tag_yaml( "magazine:", $magazine, \@found_tags );

# Koharu-version tags. Uses namespaces, and keys are lowercase
if (!defined($title)) {
$title = $hash->{"title"};
}
handle_tag_yaml( "", $hash->{"general"}, \@found_tags );
handle_tag_yaml( "male:", $hash->{"male"}, \@found_tags );
handle_tag_yaml( "female:", $hash->{"female"}, \@found_tags );
handle_tag_yaml( "mixed:", $hash->{"mixed"}, \@found_tags );
handle_tag_yaml( "other:", $hash->{"other"}, \@found_tags );
handle_tag_yaml( "artist:", $hash->{"artist"}, \@found_tags );
handle_tag_yaml( "circle:", $hash->{"circle"}, \@found_tags );
handle_tag_yaml( "parody:", $hash->{"parody"}, \@found_tags );
handle_tag_yaml( "magazine:", $hash->{"magazine"}, \@found_tags );
handle_tag_yaml( "language:", $hash->{"language"}, \@found_tags );
handle_tag_yaml( "source:", $hash->{"source"}, \@found_tags );

if ($assume_english) {
push( @found_tags, "language:english" );
}
Expand All @@ -102,4 +111,19 @@ sub tags_from_ksk_yaml {

}

sub handle_tag_yaml {
my $namespace = $_[0];
my $yamldata = $_[1];

# Check if array or string, don't iterate if string
if ( ref $yamldata eq 'ARRAY' ) {
foreach my $tag (@$yamldata) {
push( @{ $_[2] }, "$namespace$tag" );
}
} elsif ( defined($yamldata) ) {
push( @{ $_[2] }, "$namespace$yamldata" );
}

}

1;
Loading

0 comments on commit 7bdc218

Please sign in to comment.