Code Clone from GitLab Repo
This commit is contained in:
parent
5523202514
commit
4021ebb4a3
7 changed files with 882 additions and 2 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,3 +1,7 @@
|
||||||
|
ComicInfo.xml
|
||||||
|
ComicInfo.xml.template
|
||||||
|
.directory
|
||||||
|
|
||||||
# ---> Rust
|
# ---> Rust
|
||||||
# Generated by Cargo
|
# Generated by Cargo
|
||||||
# will have compiled files and executables
|
# will have compiled files and executables
|
||||||
|
|
17
Cargo.toml
Normal file
17
Cargo.toml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
[package]
|
||||||
|
name = "manga-hentai-metadata-generator"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
eframe = "0.22.0"
|
||||||
|
egui = "0.22.0"
|
||||||
|
env_logger = "0.10.0"
|
||||||
|
quick-xml = { version = "0.29.0", features = ["serde", "serialize"] }
|
||||||
|
rfd = "0.11.4"
|
||||||
|
serde = { version = "1.0.170", features = ["derive"] }
|
||||||
|
serde-xml-rs = "0.6.0"
|
||||||
|
strum = "0.25.0"
|
||||||
|
strum_macros = "0.25.0"
|
126
ComicInfo.xsd
Normal file
126
ComicInfo.xsd
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||||
|
<xs:element name="ComicInfo" nillable="true" type="ComicInfo" />
|
||||||
|
<xs:complexType name="ComicInfo">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Title" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Series" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Number" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Count" type="xs:int" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Volume" type="xs:int" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateSeries" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="AlternateNumber" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="AlternateCount" type="xs:int" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Summary" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Notes" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Year" type="xs:int" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Month" type="xs:int" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="-1" name="Day" type="xs:int" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Writer" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Penciller" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Inker" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Colorist" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Letterer" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="CoverArtist" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Editor" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Translator" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Publisher" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Imprint" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Genre" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Tags" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Web" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="0" name="PageCount" type="xs:int" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="LanguageISO" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Format" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="BlackAndWhite" type="YesNo" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="Manga" type="Manga" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Characters" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Teams" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Locations" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="ScanInformation" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="StoryArc" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="StoryArcNumber" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="SeriesGroup" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="Unknown" name="AgeRating" type="AgeRating" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" name="Pages" type="ArrayOfComicPageInfo" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" name="CommunityRating" type="Rating" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="MainCharacterOrTeam" type="xs:string" />
|
||||||
|
<xs:element minOccurs="0" maxOccurs="1" default="" name="Review" type="xs:string" />
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
<xs:simpleType name="YesNo">
|
||||||
|
<xs:restriction base="xs:string">
|
||||||
|
<xs:enumeration value="Unknown" />
|
||||||
|
<xs:enumeration value="No" />
|
||||||
|
<xs:enumeration value="Yes" />
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
<xs:simpleType name="Manga">
|
||||||
|
<xs:restriction base="xs:string">
|
||||||
|
<xs:enumeration value="Unknown" />
|
||||||
|
<xs:enumeration value="No" />
|
||||||
|
<xs:enumeration value="Yes" />
|
||||||
|
<xs:enumeration value="YesAndRightToLeft" />
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
<xs:simpleType name="Rating">
|
||||||
|
<xs:restriction base="xs:decimal">
|
||||||
|
<xs:minInclusive value="0"/>
|
||||||
|
<xs:maxInclusive value="5"/>
|
||||||
|
<xs:fractionDigits value="1"/>
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
<xs:simpleType name="AgeRating">
|
||||||
|
<xs:restriction base="xs:string">
|
||||||
|
<xs:enumeration value="Unknown" />
|
||||||
|
<xs:enumeration value="Adults Only 18+" />
|
||||||
|
<xs:enumeration value="Early Childhood" />
|
||||||
|
<xs:enumeration value="Everyone" />
|
||||||
|
<xs:enumeration value="Everyone 10+" />
|
||||||
|
<xs:enumeration value="G" />
|
||||||
|
<xs:enumeration value="Kids to Adults" />
|
||||||
|
<xs:enumeration value="M" />
|
||||||
|
<xs:enumeration value="MA15+" />
|
||||||
|
<xs:enumeration value="Mature 17+" />
|
||||||
|
<xs:enumeration value="PG" />
|
||||||
|
<xs:enumeration value="R18+" />
|
||||||
|
<xs:enumeration value="Rating Pending" />
|
||||||
|
<xs:enumeration value="Teen" />
|
||||||
|
<xs:enumeration value="X18+" />
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
<xs:complexType name="ArrayOfComicPageInfo">
|
||||||
|
<xs:sequence>
|
||||||
|
<xs:element minOccurs="0" maxOccurs="unbounded" name="Page" nillable="true" type="ComicPageInfo" />
|
||||||
|
</xs:sequence>
|
||||||
|
</xs:complexType>
|
||||||
|
<xs:complexType name="ComicPageInfo">
|
||||||
|
<xs:attribute name="Image" type="xs:int" use="required" />
|
||||||
|
<xs:attribute default="Story" name="Type" type="ComicPageType" />
|
||||||
|
<xs:attribute default="false" name="DoublePage" type="xs:boolean" />
|
||||||
|
<xs:attribute default="0" name="ImageSize" type="xs:long" />
|
||||||
|
<xs:attribute default="" name="Key" type="xs:string" />
|
||||||
|
<xs:attribute default="" name="Bookmark" type="xs:string" />
|
||||||
|
<xs:attribute default="-1" name="ImageWidth" type="xs:int" />
|
||||||
|
<xs:attribute default="-1" name="ImageHeight" type="xs:int" />
|
||||||
|
</xs:complexType>
|
||||||
|
<xs:simpleType name="ComicPageType">
|
||||||
|
<xs:list>
|
||||||
|
<xs:simpleType>
|
||||||
|
<xs:restriction base="xs:string">
|
||||||
|
<xs:enumeration value="FrontCover" />
|
||||||
|
<xs:enumeration value="InnerCover" />
|
||||||
|
<xs:enumeration value="Roundup" />
|
||||||
|
<xs:enumeration value="Story" />
|
||||||
|
<xs:enumeration value="Advertisement" />
|
||||||
|
<xs:enumeration value="Editorial" />
|
||||||
|
<xs:enumeration value="Letters" />
|
||||||
|
<xs:enumeration value="Preview" />
|
||||||
|
<xs:enumeration value="BackCover" />
|
||||||
|
<xs:enumeration value="Other" />
|
||||||
|
<xs:enumeration value="Deleted" />
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
</xs:list>
|
||||||
|
</xs:simpleType>
|
||||||
|
</xs:schema>
|
93
README.md
93
README.md
|
@ -1,3 +1,92 @@
|
||||||
# comicinfo-editor
|
# Manga + Hentai Metadata Generator
|
||||||
|
|
||||||
App for easier creation of ComicInfo.xml files.
|
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||||
|
|
||||||
|
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||||
|
|
||||||
|
## Add your files
|
||||||
|
|
||||||
|
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
|
||||||
|
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
||||||
|
|
||||||
|
```
|
||||||
|
cd existing_repo
|
||||||
|
git remote add origin https://gitlab.neshweb.net/Neshura/manga-hentai-metadata-generator.git
|
||||||
|
git branch -M main
|
||||||
|
git push -uf origin main
|
||||||
|
```
|
||||||
|
|
||||||
|
## Integrate with your tools
|
||||||
|
|
||||||
|
- [ ] [Set up project integrations](https://gitlab.neshweb.net/Neshura/manga-hentai-metadata-generator/-/settings/integrations)
|
||||||
|
|
||||||
|
## Collaborate with your team
|
||||||
|
|
||||||
|
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
|
||||||
|
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
||||||
|
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
||||||
|
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
||||||
|
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
||||||
|
|
||||||
|
## Test and Deploy
|
||||||
|
|
||||||
|
Use the built-in continuous integration in GitLab.
|
||||||
|
|
||||||
|
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
|
||||||
|
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
|
||||||
|
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
|
||||||
|
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
|
||||||
|
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
# Editing this README
|
||||||
|
|
||||||
|
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||||
|
|
||||||
|
## Suggestions for a good README
|
||||||
|
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||||
|
|
||||||
|
## Name
|
||||||
|
Choose a self-explaining name for your project.
|
||||||
|
|
||||||
|
## Description
|
||||||
|
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||||
|
|
||||||
|
## Badges
|
||||||
|
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||||
|
|
||||||
|
## Visuals
|
||||||
|
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||||
|
|
||||||
|
## Support
|
||||||
|
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||||
|
|
||||||
|
## Roadmap
|
||||||
|
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||||
|
|
||||||
|
## Contributing
|
||||||
|
State if you are open to contributions and what your requirements are for accepting them.
|
||||||
|
|
||||||
|
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||||
|
|
||||||
|
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||||
|
|
||||||
|
## Authors and acknowledgment
|
||||||
|
Show your appreciation to those who have contributed to the project.
|
||||||
|
|
||||||
|
## License
|
||||||
|
For open source projects, say how it is licensed.
|
||||||
|
|
||||||
|
## Project status
|
||||||
|
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||||
|
|
457
src/main.rs
Normal file
457
src/main.rs
Normal file
|
@ -0,0 +1,457 @@
|
||||||
|
use std::iter::Enumerate;
|
||||||
|
|
||||||
|
use egui::{widgets, TextStyle};
|
||||||
|
use metadata::{AgeRating, LanguageISO, Metadata};
|
||||||
|
|
||||||
|
use eframe::egui;
|
||||||
|
use parsers::Parsers;
|
||||||
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
|
mod metadata;
|
||||||
|
mod parsers;
|
||||||
|
|
||||||
|
const TEXT_SIZE_SMALL: f32 = 1.0;
|
||||||
|
const TEXT_SIZE_MEDIUM: f32 = 1.2;
|
||||||
|
const TEXT_SIZE_LARGE: f32 = 1.4;
|
||||||
|
|
||||||
|
fn main() -> Result<(), eframe::Error> {
|
||||||
|
env_logger::init();
|
||||||
|
let options = eframe::NativeOptions {
|
||||||
|
initial_window_size: Some(egui::vec2(1280.0, 720.0)),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
eframe::run_native(
|
||||||
|
"Metadata Generator",
|
||||||
|
options,
|
||||||
|
Box::new(|cc| {
|
||||||
|
cc.egui_ctx.set_pixels_per_point(TEXT_SIZE_MEDIUM);
|
||||||
|
Box::<Generator>::default()
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Generator<'a> {
|
||||||
|
show_all: bool,
|
||||||
|
metadata: Vec<Metadata<'a>>,
|
||||||
|
selected_parser: Parsers,
|
||||||
|
use_file: bool,
|
||||||
|
meta_path: Option<String>,
|
||||||
|
bundle: bool,
|
||||||
|
bundle_source: Option<String>,
|
||||||
|
bundle_path: Option<String>,
|
||||||
|
footer_height: f32,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Generator<'_> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
show_all: false,
|
||||||
|
metadata: vec![Metadata::default()],
|
||||||
|
selected_parser: Parsers::JNovel,
|
||||||
|
use_file: true,
|
||||||
|
meta_path: None,
|
||||||
|
bundle: false,
|
||||||
|
bundle_source: None,
|
||||||
|
bundle_path: None,
|
||||||
|
footer_height: 0.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl eframe::App for Generator<'_> {
|
||||||
|
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
||||||
|
// Non-Metadata Options
|
||||||
|
egui::SidePanel::right("Options")
|
||||||
|
.resizable(false)
|
||||||
|
.min_width(ctx.screen_rect().width() / 3.0)
|
||||||
|
.max_width(ctx.screen_rect().width() / 3.0)
|
||||||
|
.show(ctx, |panel| {
|
||||||
|
panel.heading("Options");
|
||||||
|
panel.horizontal(|row| {
|
||||||
|
row.label("Parser: ");
|
||||||
|
egui::containers::ComboBox::from_label("")
|
||||||
|
.selected_text(self.selected_parser.to_string())
|
||||||
|
.show_ui(row, |ui| {
|
||||||
|
for rating in Parsers::iter() {
|
||||||
|
let text = rating.to_string().clone();
|
||||||
|
if ui
|
||||||
|
.selectable_value(&mut self.selected_parser, rating, text)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
match self.selected_parser {
|
||||||
|
Parsers::Fakku | Parsers::Irodori => {
|
||||||
|
self.use_file = false; // TODO change to use Parser default
|
||||||
|
}
|
||||||
|
Parsers::JNovel => {
|
||||||
|
self.use_file = true; // TODO change to use Parser default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
panel.horizontal(|row| {
|
||||||
|
row.label("Parser Source: ");
|
||||||
|
if row
|
||||||
|
.add(widgets::SelectableLabel::new(self.use_file, "File"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
self.use_file = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if row
|
||||||
|
.add(widgets::SelectableLabel::new(!self.use_file, "URL"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
self.use_file = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let file_label;
|
||||||
|
if self.use_file {
|
||||||
|
file_label = "File Path";
|
||||||
|
} else {
|
||||||
|
file_label = "URL";
|
||||||
|
}
|
||||||
|
text_input_option(panel, &mut self.meta_path, file_label, self.use_file);
|
||||||
|
|
||||||
|
// TODO this feels wrong, there must be a better way
|
||||||
|
panel.add_space(self.footer_height * 0.1);
|
||||||
|
panel.separator();
|
||||||
|
panel.add_space(self.footer_height * 0.1);
|
||||||
|
|
||||||
|
panel.horizontal(|row| {
|
||||||
|
row.label("Perform Bundle: ");
|
||||||
|
row.add(widgets::Checkbox::new(&mut self.bundle, ""));
|
||||||
|
});
|
||||||
|
|
||||||
|
if self.bundle {
|
||||||
|
text_input_option(panel, &mut self.bundle_source, "Images Folder", true);
|
||||||
|
text_input_option(panel, &mut self.bundle_path, "Output Path", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
panel.add_space(self.footer_height * 2.0);
|
||||||
|
|
||||||
|
panel.horizontal(|elem| {
|
||||||
|
elem.vertical_centered(|centered| {
|
||||||
|
if centered.button("Generate Metadata").clicked() {
|
||||||
|
// Run Metadata Generation
|
||||||
|
// DO NOT SAVE RESULTS YET ONLY POPULATE DATA
|
||||||
|
println!("Ran Generation (not yet)");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
panel.add_space(panel.available_height() - self.footer_height);
|
||||||
|
|
||||||
|
self.footer_height = panel
|
||||||
|
.horizontal(|row| {
|
||||||
|
let ppp = ctx.pixels_per_point();
|
||||||
|
row.label("Text Size:");
|
||||||
|
if row
|
||||||
|
.add(widgets::RadioButton::new(ppp == TEXT_SIZE_SMALL, "Small"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
ctx.set_pixels_per_point(TEXT_SIZE_SMALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if row
|
||||||
|
.add(widgets::RadioButton::new(ppp == TEXT_SIZE_MEDIUM, "Medium"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
ctx.set_pixels_per_point(TEXT_SIZE_MEDIUM);
|
||||||
|
}
|
||||||
|
|
||||||
|
if row
|
||||||
|
.add(widgets::RadioButton::new(ppp == TEXT_SIZE_LARGE, "Large"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
ctx.set_pixels_per_point(TEXT_SIZE_LARGE);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.response
|
||||||
|
.rect
|
||||||
|
.height();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Metadata Options
|
||||||
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
|
ui.heading("Metadata");
|
||||||
|
|
||||||
|
// Title & Series
|
||||||
|
text_input(ui, &mut self.metadata[0].series, "Series", false);
|
||||||
|
text_input(ui, &mut self.metadata[0].title, "Title", false);
|
||||||
|
|
||||||
|
// Volume and Chapter Info
|
||||||
|
ui.horizontal(|row| {
|
||||||
|
row.label("Volume:");
|
||||||
|
if row.button("-").clicked() {
|
||||||
|
self.metadata[0].volume -= 1;
|
||||||
|
}
|
||||||
|
row.label(format!("{}", self.metadata[0].volume));
|
||||||
|
if row.button("+").clicked() {
|
||||||
|
self.metadata[0].volume += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
row.label("Chapter:");
|
||||||
|
if row.button("-").clicked() {
|
||||||
|
self.metadata[0].number -= 1;
|
||||||
|
}
|
||||||
|
row.label(format!("{}", self.metadata[0].number));
|
||||||
|
if row.button("+").clicked() {
|
||||||
|
self.metadata[0].number += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ui.horizontal(|row| {
|
||||||
|
row.label("Series Chapter Count:");
|
||||||
|
if row.button("-").clicked() {
|
||||||
|
self.metadata[0].count -= 1;
|
||||||
|
}
|
||||||
|
row.label(format!("{}", self.metadata[0].count));
|
||||||
|
if row.button("+").clicked() {
|
||||||
|
self.metadata[0].count += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO Multiline Summary
|
||||||
|
ui.label("TODO: Summary Edit");
|
||||||
|
if let Some(summary) = &self.metadata[0].summary {
|
||||||
|
ui.label(summary);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Date Inputs
|
||||||
|
let glyph_width = ctx
|
||||||
|
.fonts(|f| -> f32 { f.glyph_width(&TextStyle::Body.resolve(ui.style()), '0') });
|
||||||
|
|
||||||
|
let mut year_text = self.metadata[0].year.to_string();
|
||||||
|
|
||||||
|
ui.horizontal(|row| {
|
||||||
|
row.label("Release Date:");
|
||||||
|
if row
|
||||||
|
.add(
|
||||||
|
widgets::text_edit::TextEdit::singleline(&mut year_text)
|
||||||
|
.desired_width(5.0 * glyph_width),
|
||||||
|
)
|
||||||
|
.changed()
|
||||||
|
{
|
||||||
|
let trimmed = year_text.trim();
|
||||||
|
if trimmed == "0" {
|
||||||
|
self.metadata[0].year = -1;
|
||||||
|
self.metadata[0].month = -1;
|
||||||
|
self.metadata[0].day = -1;
|
||||||
|
} else {
|
||||||
|
self.metadata[0].year =
|
||||||
|
trimmed.parse::<i16>().unwrap_or(self.metadata[0].year);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if self.metadata[0].year >= 1970 {
|
||||||
|
let mut month_text = self.metadata[0].month.to_string();
|
||||||
|
if row
|
||||||
|
.add(
|
||||||
|
widgets::text_edit::TextEdit::singleline(&mut month_text)
|
||||||
|
.desired_width(3.0 * glyph_width),
|
||||||
|
)
|
||||||
|
.changed()
|
||||||
|
{
|
||||||
|
let trimmed = month_text.trim();
|
||||||
|
if trimmed == "0" {
|
||||||
|
self.metadata[0].month = -1;
|
||||||
|
self.metadata[0].day = -1;
|
||||||
|
} else {
|
||||||
|
self.metadata[0].month = month_text
|
||||||
|
.trim()
|
||||||
|
.parse::<i8>()
|
||||||
|
.unwrap_or(self.metadata[0].month);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if self.metadata[0].month >= 0 {
|
||||||
|
let mut day_text = self.metadata[0].day.to_string();
|
||||||
|
if row
|
||||||
|
.add(
|
||||||
|
widgets::text_edit::TextEdit::singleline(&mut day_text)
|
||||||
|
.desired_width(3.0 * glyph_width),
|
||||||
|
)
|
||||||
|
.changed()
|
||||||
|
{
|
||||||
|
let trimmed = day_text.trim();
|
||||||
|
if trimmed == "0" {
|
||||||
|
self.metadata[0].day = -1;
|
||||||
|
} else {
|
||||||
|
self.metadata[0].day = day_text
|
||||||
|
.trim()
|
||||||
|
.parse::<i8>()
|
||||||
|
.unwrap_or(self.metadata[0].day);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// People involved
|
||||||
|
text_input_option(ui, &mut self.metadata[0].writer, "Author", false);
|
||||||
|
text_input_option(ui, &mut self.metadata[0].letterer, "Typesetter", false);
|
||||||
|
text_input_option(ui, &mut self.metadata[0].editor, "Editor", false);
|
||||||
|
text_input_option(ui, &mut self.metadata[0].translator, "Translator", false);
|
||||||
|
text_input_option(ui, &mut self.metadata[0].publisher, "Publisher", false);
|
||||||
|
|
||||||
|
/*
|
||||||
|
tags: Vec<String>,
|
||||||
|
characters: Vec<String>,
|
||||||
|
*/
|
||||||
|
text_input(ui, &mut self.metadata[0].genre, "Genre", false);
|
||||||
|
// TODO tag list (List of bordered labels with plus that opens a new text edit)
|
||||||
|
ui.horizontal(|row| {
|
||||||
|
row.label("Page Count:");
|
||||||
|
if row.button("-").clicked() {
|
||||||
|
self.metadata[0].page_count -= 1;
|
||||||
|
}
|
||||||
|
row.label(format!("{}", self.metadata[0].page_count));
|
||||||
|
if row.button("+").clicked() {
|
||||||
|
self.metadata[0].page_count += 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//text_input(ui, &mut self.metadata[0].page_count, "Page Count", false);
|
||||||
|
|
||||||
|
// Lang Drop Down
|
||||||
|
ui.horizontal(|row| {
|
||||||
|
row.label("Language: ");
|
||||||
|
egui::containers::ComboBox::from_label("a")
|
||||||
|
.selected_text(self.metadata[0].language.to_string())
|
||||||
|
.show_ui(row, |ui| {
|
||||||
|
for language in LanguageISO::iter() {
|
||||||
|
let text = language.to_string().clone();
|
||||||
|
ui.selectable_value(&mut self.metadata[0].language, language, text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO same as with Tags but for characters
|
||||||
|
|
||||||
|
// Age Rating Drop Down
|
||||||
|
ui.horizontal(|row| {
|
||||||
|
row.label("Age Rating: ");
|
||||||
|
egui::containers::ComboBox::from_label("b")
|
||||||
|
.selected_text(self.metadata[0].age_rating.to_string())
|
||||||
|
.show_ui(row, |ui| {
|
||||||
|
for rating in AgeRating::iter() {
|
||||||
|
let text = rating.to_string().clone();
|
||||||
|
ui.selectable_value(&mut self.metadata[0].age_rating, rating, text);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ui.horizontal(|elem| {
|
||||||
|
elem.vertical_centered(|centered| {
|
||||||
|
if centered.button("Save Metadata").clicked() {
|
||||||
|
// Run Metadata Generation
|
||||||
|
// DO NOT SAVE RESULTS YET ONLY POPULATE DATA
|
||||||
|
self.metadata[0].save_to_xml("/home/neshura/Repositories/manga-hentai-metadata-generator/ComicInfo.xml")
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
if self.show_all {
|
||||||
|
ui.label(format!("Not Implemented yet."));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn text_input_option(
|
||||||
|
ui: &mut egui::Ui,
|
||||||
|
option: &mut Option<String>,
|
||||||
|
label: &str,
|
||||||
|
file_picker: bool,
|
||||||
|
) -> egui::InnerResponse<()> {
|
||||||
|
let zero_width =
|
||||||
|
2.0 * ui.fonts(|f| -> f32 { f.glyph_width(&TextStyle::Body.resolve(ui.style()), '0') });
|
||||||
|
|
||||||
|
ui.horizontal(|row| {
|
||||||
|
row.label(format!("{}:", label));
|
||||||
|
if let Some(ref mut text) = option {
|
||||||
|
let dynamic_width = zero_width
|
||||||
|
+ text
|
||||||
|
.chars()
|
||||||
|
.map(|c| {
|
||||||
|
row.fonts(|f| -> f32 {
|
||||||
|
f.glyph_width(&TextStyle::Body.resolve(row.style()), c)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.sum::<f32>();
|
||||||
|
|
||||||
|
row.add(
|
||||||
|
widgets::text_edit::TextEdit::singleline(text).desired_width(
|
||||||
|
if dynamic_width >= zero_width * 3.0 {
|
||||||
|
dynamic_width
|
||||||
|
} else {
|
||||||
|
zero_width * 3.0
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
if text == "" {
|
||||||
|
*option = None;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
let mut init = "".to_string();
|
||||||
|
row.add(
|
||||||
|
widgets::text_edit::TextEdit::singleline(&mut init).desired_width(zero_width * 3.0),
|
||||||
|
);
|
||||||
|
if init != "" {
|
||||||
|
*option = Some(init);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if file_picker {
|
||||||
|
if row.button("...").clicked() {
|
||||||
|
if let Some(path) = rfd::FileDialog::new().pick_file() {
|
||||||
|
*option = Some(path.display().to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn text_input(
|
||||||
|
ui: &mut egui::Ui,
|
||||||
|
option: &mut String,
|
||||||
|
label: &str,
|
||||||
|
file_picker: bool,
|
||||||
|
) -> egui::InnerResponse<()> {
|
||||||
|
let zero_width =
|
||||||
|
2.0 * ui.fonts(|f| -> f32 { f.glyph_width(&TextStyle::Body.resolve(ui.style()), '0') });
|
||||||
|
|
||||||
|
ui.horizontal(|row| {
|
||||||
|
row.label(format!("{}:", label));
|
||||||
|
let dynamic_width = zero_width
|
||||||
|
+ option
|
||||||
|
.chars()
|
||||||
|
.map(|c| {
|
||||||
|
row.fonts(|f| -> f32 {
|
||||||
|
f.glyph_width(&TextStyle::Body.resolve(row.style()), c)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.sum::<f32>();
|
||||||
|
|
||||||
|
row.add(
|
||||||
|
widgets::text_edit::TextEdit::singleline(option).desired_width(
|
||||||
|
if dynamic_width >= zero_width * 3.0 {
|
||||||
|
dynamic_width
|
||||||
|
} else {
|
||||||
|
zero_width * 3.0
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
if file_picker {
|
||||||
|
if row.button("...").clicked() {
|
||||||
|
if let Some(path) = rfd::FileDialog::new().pick_file() {
|
||||||
|
*option = path.display().to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
179
src/metadata/mod.rs
Normal file
179
src/metadata/mod.rs
Normal file
|
@ -0,0 +1,179 @@
|
||||||
|
use std::{fs::File, io::{Write, Cursor}};
|
||||||
|
use quick_xml::{se::Serializer, events::BytesStart};
|
||||||
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
|
use serde_xml_rs::{to_string, to_writer};
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
|
||||||
|
pub(crate) struct Metadata<'a> {
|
||||||
|
#[serde(rename = "@xmlns:xsi")]
|
||||||
|
xsi: &'a str,
|
||||||
|
|
||||||
|
#[serde(rename = "@xsi:noNamespaceSchemaLocation")]
|
||||||
|
namespace: &'a str,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Title"))]
|
||||||
|
pub(crate) title: String,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Series"))]
|
||||||
|
pub(crate) series: String,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Number"))]
|
||||||
|
pub(crate) number: u16,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Count"))]
|
||||||
|
pub(crate) count: i16,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Volume"))]
|
||||||
|
pub(crate) volume: i16,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Summary"))]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub(crate) summary: Option<String>,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Year"))]
|
||||||
|
pub(crate) year: i16,
|
||||||
|
#[serde(rename(serialize="Month"))]
|
||||||
|
pub(crate) month: i8,
|
||||||
|
#[serde(rename(serialize="Day"))]
|
||||||
|
pub(crate) day: i8,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Writer"))]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub(crate) writer: Option<String>,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Letterer"))]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub(crate) letterer: Option<String>,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Editor"))]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub(crate) editor: Option<String>,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Translator"))]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub(crate) translator: Option<String>,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Publisher"))]
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub(crate) publisher: Option<String>,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Genre"))]
|
||||||
|
pub(crate) genre: String,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Tags"))]
|
||||||
|
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub(crate) tags: Vec<String>,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="PageCount"))]
|
||||||
|
pub(crate) page_count: u16,
|
||||||
|
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub(crate) language: LanguageISO,
|
||||||
|
|
||||||
|
#[serde(rename(serialize="Characters"))]
|
||||||
|
#[serde(skip_serializing_if = "Vec::is_empty")]
|
||||||
|
pub(crate) characters: Vec<String>,
|
||||||
|
|
||||||
|
#[serde(flatten)]
|
||||||
|
pub(crate) age_rating: AgeRating
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Metadata<'_> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
xsi: "http://www.w3.org/2001/XMLSchema-instance",
|
||||||
|
namespace: "ComicInfo.xsd",
|
||||||
|
title: "".into(),
|
||||||
|
series: "".into(),
|
||||||
|
number: 0,
|
||||||
|
count: -1,
|
||||||
|
volume: -1,
|
||||||
|
summary: None,
|
||||||
|
year: -1,
|
||||||
|
month: -1,
|
||||||
|
day: -1,
|
||||||
|
writer: None,
|
||||||
|
letterer: None,
|
||||||
|
editor: None,
|
||||||
|
translator: None,
|
||||||
|
publisher: None,
|
||||||
|
genre: "".into(),
|
||||||
|
tags: vec![],
|
||||||
|
page_count: 0,
|
||||||
|
language: LanguageISO::EN,
|
||||||
|
characters: vec![],
|
||||||
|
age_rating: AgeRating::Unknown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Metadata<'_> {
|
||||||
|
pub(crate) fn save_to_xml(&self, path: &str) {
|
||||||
|
let mut file = File::create(path).unwrap();
|
||||||
|
let mut buffer = String::new();
|
||||||
|
let root = "ComicInfo";
|
||||||
|
|
||||||
|
let mut ser = Serializer::with_root(&mut buffer, Some(root)).unwrap();
|
||||||
|
ser.indent(' ', 4);
|
||||||
|
|
||||||
|
self.serialize(ser).unwrap();
|
||||||
|
file.write(buffer.as_bytes()).unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(strum_macros::Display, Debug, PartialEq, strum_macros::EnumIter, Serialize, Deserialize, Clone)]
|
||||||
|
#[serde(tag = "AgeRating")]
|
||||||
|
pub(crate) enum AgeRating {
|
||||||
|
#[strum(serialize="Unknown")]
|
||||||
|
Unknown,
|
||||||
|
#[strum(serialize="Adults Only 18+")]
|
||||||
|
#[serde(rename="Adults Only 18+")]
|
||||||
|
AdultsOnly,
|
||||||
|
#[strum(serialize="Early Childhood")]
|
||||||
|
#[serde(rename="Early Childhood")]
|
||||||
|
EarlyChildhood,
|
||||||
|
#[strum(serialize="Everyone")]
|
||||||
|
Everyone,
|
||||||
|
#[strum(serialize="Everyone 10+")]
|
||||||
|
#[serde(rename="Everyone 10+")]
|
||||||
|
Everyone10,
|
||||||
|
#[strum(serialize="G")]
|
||||||
|
G,
|
||||||
|
#[strum(serialize="Kids to Adults")]
|
||||||
|
#[serde(rename="Kids to Adults")]
|
||||||
|
KidsAdults,
|
||||||
|
#[strum(serialize="M")]
|
||||||
|
M,
|
||||||
|
#[strum(serialize="MA15+")]
|
||||||
|
#[serde(rename="MA15+")]
|
||||||
|
MA15,
|
||||||
|
#[strum(serialize="Mature 17+")]
|
||||||
|
#[serde(rename="Mature 17+")]
|
||||||
|
Mature,
|
||||||
|
#[strum(serialize="PG")]
|
||||||
|
PG,
|
||||||
|
#[strum(serialize="R18+")]
|
||||||
|
#[serde(rename="R18+")]
|
||||||
|
R18,
|
||||||
|
#[strum(serialize="Rating Pending")]
|
||||||
|
#[serde(rename="Rating Pending")]
|
||||||
|
RatingPending,
|
||||||
|
#[strum(serialize="Teen")]
|
||||||
|
Teen,
|
||||||
|
#[strum(serialize="X18+")]
|
||||||
|
#[serde(rename="X18+")]
|
||||||
|
X18
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(strum_macros::Display, Debug, PartialEq, strum_macros::EnumIter, Serialize, Deserialize, Clone)]
|
||||||
|
#[serde(tag = "LanguageISO")]
|
||||||
|
pub(crate) enum LanguageISO {
|
||||||
|
#[strum(serialize="en")]
|
||||||
|
#[serde(rename="en")]
|
||||||
|
EN,
|
||||||
|
#[strum(serialize="jp")]
|
||||||
|
#[serde(rename="jp")]
|
||||||
|
JP
|
||||||
|
}
|
8
src/parsers/mod.rs
Normal file
8
src/parsers/mod.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#[derive(strum_macros::Display, Debug, PartialEq, strum_macros::EnumIter)]
|
||||||
|
pub(crate) enum Parsers {
|
||||||
|
#[strum(serialize="Irodori Comics")]
|
||||||
|
Irodori,
|
||||||
|
Fakku,
|
||||||
|
#[strum(serialize="J-Novel Club")]
|
||||||
|
JNovel
|
||||||
|
}
|
Reference in a new issue