Compare commits

..

14 Commits

Author SHA1 Message Date
Xarvex
08a10ef288 chore(thumb_renderer): bump Pillow
Builds upon #1065, mkdocs-material has now bumped the Pillow version
being used, and now the built in AVIF support can be used
2025-11-24 17:10:24 -06:00
Sola-ris
6397b228eb feat: add windows runner for pytest (#1201)
* feat: run tests on windows and macOS.

* resue steps via anchors.

* remove macOS job.
2025-11-23 20:23:41 -08:00
Trigam
4d882a7156 fix: 'Add Tag to Selected' action fails (#1224)
* Fix

* Fix preview panel being reset

* Fix 'Add Tag to Selected' not emitting badge signals
2025-11-23 20:20:14 -08:00
Travis Abendshien
4c0cb1648f chore: update PULL_REQUEST_TEMPLATE.md 2025-11-14 15:31:13 -08:00
CallMeHein
0529925cd1 fix: "Search for Tag" in Tag Manager executes multiple queries (#1173)
* test: add test to ensure actions are replaced when widgets are replaced

* fix: disconnect previous action before adding new action
2025-11-07 16:18:07 -08:00
Timo Gottszky
5dcad418f7 fix(nix): replace wrapGAppsHook with wrapGAppsHook3 (#1189)
wrapGAppsHook has been aliased to wrapGAppsHook3 for a long time.
Recently this alias was converted to a throw, breaking the build with
newer nixpkgs versions.
2025-11-07 16:28:18 -06:00
Travis Abendshien
615978e5a6 docs: update README 2025-10-08 01:39:06 -07:00
Travis Abendshien
e833473c5b chore: bump version to v9.5.6 2025-10-08 01:20:39 -07:00
TheBobBobs
c9f5347182 fix: add periodic yield to save_new_files (#1040)
* fix: add periodic yield to save_new_files

* move refresh_dir.py

* use variable for batch size
2025-10-07 21:16:43 -07:00
Trigam
db7b126725 fix(search): return results for A AND A type search (#1138) 2025-10-07 20:57:29 -07:00
Travis Abendshien
26803b0d42 ui(settings): enable Italian 2025-10-07 20:52:23 -07:00
Weblate (bot)
d86a9bfb7b translations: update Italian (#1154)
Currently translated at 98.5% (352 of 357 strings)

Translated using Weblate (Italian)

Currently translated at 98.5% (352 of 357 strings)

Translated using Weblate (Italian)

Currently translated at 91.5% (327 of 357 strings)

Translated using Weblate (Italian)

Currently translated at 49.5% (177 of 357 strings)




Translate-URL: https://hosted.weblate.org/projects/tagstudio/strings/it/
Translation: TagStudio/Strings

Co-authored-by: Omni <blackbass175@gmail.com>
Co-authored-by: Travis Abendshien <46939827+CyanVoxel@users.noreply.github.com>
2025-10-07 20:49:57 -07:00
Travis Abendshien
137c750595 docs: crop screenshots 2025-10-01 22:01:16 -07:00
Travis Abendshien
9f44834356 fix(docs): fix typos 2025-10-01 21:55:12 -07:00
38 changed files with 926 additions and 1502 deletions

View File

@@ -4,7 +4,8 @@
^^^ Summarize the changes done and why they were done above.
By submitting this pull request, you certify that you have read the
[CONTRIBUTING.md](https://github.com/TagStudioDev/TagStudio/blob/main/CONTRIBUTING.md).
[Contributing](https://docs.tagstud.io/contributing) page on our documentation site,
or in the project's [CONTRIBUTING.md](https://github.com/TagStudioDev/TagStudio/blob/main/docs/contributing.md) file.
IMPORTANT FOR FEATURES: Please verify that a feature request or some other form
of communication with maintainers was already conducted in terms of approving.

View File

@@ -4,21 +4,24 @@ name: pytest
on: [push, pull_request]
jobs:
pytest:
name: Run pytest
pytest-linux:
name: Run pytest (Linux)
runs-on: ubuntu-24.04
steps:
- name: Checkout repo
- &checkout
name: Checkout repo
uses: actions/checkout@v4
- name: Setup Python
- &setup-python
name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- name: Install Python dependencies
- &install-dependencies
name: Install Python dependencies
run: |
python -m pip install --upgrade uv
uv pip install --system .[pytest]
@@ -52,10 +55,27 @@ jobs:
name: coverage
path: coverage.xml
pytest-windows:
name: Run pytest (Windows)
runs-on: windows-2025
steps:
- *checkout
- *setup-python
- *install-dependencies
- name: Install system dependencies
run: |
choco install ripgrep
- name: Execute pytest
run: |
pytest
coverage:
name: Check coverage
runs-on: ubuntu-latest
needs: pytest
needs: pytest-linux
steps:
- name: Fetch coverage

286
README.md
View File

@@ -1,120 +1,92 @@
# TagStudio: A User-Focused Document Management System
# TagStudio: A User-Focused Photo & File Management System
[![Translation](https://hosted.weblate.org/widget/tagstudio/strings/svg-badge.svg)](https://hosted.weblate.org/projects/tagstudio/strings/)
[![Downloads](https://img.shields.io/github/downloads/TagStudioDev/TagStudio/total.svg?maxAge=2592001)](https://github.com/TagStudioDev/TagStudio/releases)
[![Translations](https://hosted.weblate.org/widget/tagstudio/strings/svg-badge.svg)](https://hosted.weblate.org/projects/tagstudio/strings/)
[![PyTest](https://github.com/TagStudioDev/TagStudio/actions/workflows/pytest.yaml/badge.svg)](https://github.com/TagStudioDev/TagStudio/actions/workflows/pytest.yaml)
[![MyPy](https://github.com/TagStudioDev/TagStudio/actions/workflows/mypy.yaml/badge.svg)](https://github.com/TagStudioDev/TagStudio/actions/workflows/mypy.yaml)
[![Ruff](https://github.com/TagStudioDev/TagStudio/actions/workflows/ruff.yaml/badge.svg)](https://github.com/TagStudioDev/TagStudio/actions/workflows/ruff.yaml)
[![Downloads](https://img.shields.io/github/downloads/TagStudioDev/TagStudio/total.svg?maxAge=2592001)](https://github.com/TagStudioDev/TagStudio/releases)
<p align="center">
<img width="60%" src="docs/assets/github_header.png">
<img width="60%" src="docs/assets/ts-9-3_logo_text.png">
</p>
TagStudio is a photo & file organization application with an underlying tag-based system that focuses on giving freedom and flexibility to the user. No proprietary programs or formats, no sea of sidecar files, and no complete upheaval of your filesystem structure. **Read the documentation and more at [docs.tagstud.io](https://docs.tagstud.io)!**
> [!NOTE]
> Thank you for being patient as we've migrated our database backend from JSON to SQL! The previous warnings about the main branch being experimental and unsupported have now been removed, and any pre-existing library save files created with official TagStudio releases are able to be opened and migrated with the new v9.5+ releases!
> [!IMPORTANT]
> This project is still in an early state. There are many missing optimizations and QoL features, as well as the presence of general quirks and occasional jankiness. Making frequent backups of your library save data is **always** important, regardless of what state the program is in.
>
> With this in mind, TagStudio will _NOT:_
>
> - Touch, move, or mess with your files in any way _(unless explicitly using the "Delete File(s)" feature, which is locked behind a confirmation dialog)_.
> - Ask you to recreate your tags or libraries after new releases. It's our highest priority to ensure that your data safely and smoothly transfers over to newer versions.
> - Cause you to suddenly be able to recall your 10 trillion downloaded images that you probably haven't even seen firsthand before. You're in control here, and even tools out there that use machine learning still needed to be verified by human eyes before being deemed accurate.
<p align="center">
<img width="80%" src="docs/assets/screenshot.png" alt="TagStudio Screenshot">
</p>
<p align="center">
<i>TagStudio Alpha v9.5.0 running on macOS Sequoia.</i>
<i>TagStudio Alpha v9.5.5 running on macOS Sequoia.</i>
</p>
## Contents
- [Goals](#goals)
- [Priorities](#priorities)
- [Current Features](#current-features)
- [Contributing](#contributing)
- [Feature Highlights](#feature-highlights)
- [Basic Usage](#basic-usage)
- [Installation](#installation)
- [Usage](#usage)
- [Goals & Priorities](#goals--priorities)
- [FAQ](#faq)
## Goals
- To achieve a portable, private, extensible, open-format, and feature-rich system of organizing and rediscovering files.
- To provide powerful methods for organization, notably the concept of tag inheritance, or "taggable tags" _(and in the near future, the combination of composition-based tags)._
- To create an implementation of such a system that is resilient against a users actions outside the program (modifying, moving, or renaming files) while also not burdening the user with mandatory sidecar files or requiring them to change their existing file structures and workflows.
- To support a wide range of users spanning across different platforms, multi-user setups, and those with large (several terabyte) libraries.
- To make the dang thing look nice, too. Its 2025, not 1995.
## Priorities
1. **The concept.** Even if TagStudio as an application fails, Id hope that the idea lives on in a superior project. The [goals](#goals) outlined above dont reference TagStudio once - _TagStudio_ is what references the _goals._
2. **The system.** Frontends and implementations can vary, as they should. The core underlying metadata management system is what should be interoperable between different frontends, programs, and operating systems. A standard implementation for this should settle as development continues. This opens up the doors for improved and varied clients, integration with third-party applications, and more.
3. **The application.** If nothing else, TagStudio the application serves as the first (and so far only) implementation for this system of metadata management. This has the responsibility of doing the idea justice and showing just whats possible when it comes to user file management.
4. (The name.) I think its fine for an app or client, but it doesnt really make sense for a system or standard. I suppose this will evolve with time...
## Contributing
If you're interested in contributing to TagStudio, please take a look at the [contribution guidelines](/CONTRIBUTING.md) for how to get started!
Translation hosting generously provided by [Weblate](https://weblate.org/en/). Check out our [project page](https://hosted.weblate.org/projects/tagstudio/) to help translate TagStudio!
## Current Features
## Feature Highlights
### Libraries
- Create libraries/vaults centered around a system directory. Libraries contain a series of entries: the representations of your files combined with metadata fields. Each entry represents a file in your librarys directory, and is linked to its location.
- Address moved, deleted, or otherwise "unlinked" files by using the "Fix Unlinked Entries" option in the Tools menu.
A TagStudio library contains all of your tags, fields for a set of files based on one of your system directories. Similar to how Obsidian [vaults](https://help.obsidian.md/vault) function, TagStudio libraries act as a layer on top of your existing folders and file structure, and don't require your to move or duplicate files.
### Tagging + Custom Metadata
TagStudio places a `.TagStudio` folder in the folder you open as a library. Files included in your library are referred to as "entries", and are kept track of inside of a SQLite database inside the `.TagStudio` folder along with tags and other library data.
- Add custom powerful tags to your library entries
- Add metadata to your library entries, including:
- Name, Author, Artist (Single-Line Text Fields)
- Description, Notes (Multiline Text Fields)
- Create rich tags composed of a name, color, a list of aliases, and a list of "parent tags" - these being tags in which these tags inherit values from.
- Copy and paste tags and fields across file entries
- Automatically organize tags into groups based on parent tags marked as "categories"
- Generate tags from your existing folder structure with the "Folders to Tags" macro (NOTE: these tags do NOT sync with folders after they are created)
### File Entries
### Search
All file types are supported in TagStudio libraries, just not all have dedicated preview support. For a full list of filetypes with supported previews, see the "[Supported Previews](https://docs.tagstud.io/preview-support)" page on the documentation site. There's also playback support for videos, audio files, and supported animated image formats.
For a generalized list of what's currently supported:
- **Images**
- Raster Images (JPEG, PNG, etc.)
- Vector (SVG)
- Animated (GIF, WEBP, APNG)
- RAW Formats
- **Videos**
- **Plaintext Files**
- **Documents** _(If supported)_
- **eBooks** _(If supported)_
- **Photoshop PSDs**, **Blender Projects**, **Krita Projects**, and more!
### [Tags](https://docs.tagstud.io/tags) and [Fields](https://docs.tagstud.io/fields)
Tags represent an object or attribute - this could be a person, place, object, concept, and more. Unlike most tagging systems, TagStudio tags are not solely represented by a line of text or a hashtag. Tags in TagStudio consist of several properties and relationships that give extra customization, searching power, and ease of tagging that cannot be achieved by string-based tags alone. TagStudio tags are designed to be as simple or as complex as you'd like, giving options to users of all skill levels and use cases.
Tags currently consist of the following attributes:
- **Name**: The full name for your tag. **_This does NOT have to be unique!_**
- **Shorthand Name**: The shortest alternate name for your tag, used for abbreviations.
- **Aliases**: Alternate names your tag goes by.
- **Color**: The display color of your tag.
- **Parent Tags**: Other tags in which this tag inherits from. In practice, this means that this tag can be substituted in searches for any listed parent tags.
- Parent tags checked with the "disambiguation" checkbox next to them will be used to help disambiguate tag names that may not be unique.
- For example: If you had a tag for "Freddy Fazbear", you might add "Five Nights at Freddy's" as one of the parent tags. If the disambiguation box is checked next to "Five Nights at Freddy's" parent tag, then the tag "Freddy Fazbear" will display as "Freddy Fazbear (Five Nights at Freddy's)". Furthermore, if the "Five Nights at Freddy's" tag has a shorthand like "FNAF", then the "Freddy Fazbear" tag will display as "Freddy Fazbear (FNAF)".
- **Is Category**: A property that when checked, treats this tag as a category in the preview panel.
Fields, like tags, are additional pieces of custom metadata that you can add to your file entries. Fields currently have several hardcoded names (e.g. "Title", "Author", "Series") but custom field names are planned for an upcoming update.
Field types currently include:
- **Text Lines**: Single lines of text.
- **Text Boxes**: Multi-line pieces of text.
- **Datetimes**: Dates and times.
### [Search](https://docs.tagstud.io/search)
- Search for file entries based on tags, file path (`path:`), file types (`filetype:`), and even media types! (`mediatype:`). Path searches currently use [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) syntax, so you may need to wrap your filename or filepath in asterisks while searching. This will not be strictly necessary in future versions of the program.
- Use and combine boolean operators (`AND`, `OR`, `NOT`) along with parentheses groups, quotation escaping, and underscore substitution to create detailed search queries
- Use special search conditions (`special:untagged` and `special:empty`) to find file entries without tags or fields, respectively
### File Entries
## Basic Usage
- Nearly all file types are supported in TagStudio libraries - just not all have dedicated thumbnail support.
- Preview most image file types, animated GIFs, videos, plain text documents, audio files, Blender projects, and more!
- Open files or file locations by right-clicking on thumbnails and previews and selecting the respective context menu options. You can also click on the preview panel image to open the file, and click the file path label to open its location.
- Delete files from both your library and drive by right-clicking the thumbnail(s) and selecting the "Move to Trash"/"Move to Recycle Bin" option.
> [!NOTE]
> For more information on the project itself, please see the [FAQ](#faq) section as well as the [documentation](https://docs.tagstud.io/)!
## Installation
To download executable builds of TagStudio, visit the [Releases](https://github.com/TagStudioDev/TagStudio/releases) page of the GitHub repository and download the latest release for your system under the "Assets" section at the bottom of the release.
TagStudio has builds for **Windows**, **macOS** _(Apple Silicon & Intel)_, and **Linux**. We also offer portable releases for Windows and Linux which are self-contained and easier to move around.
For detailed instructions, installation help, and instructions for developing for TagStudio, please see the "[Installation](https://docs.tagstud.io/install/)" page on our documentation website.
<!-- prettier-ignore -->
> [!CAUTION]
> **We do not currently publish TagStudio to any package managers. Any TagStudio distributions outside of the GitHub [Releases](https://github.com/TagStudioDev/TagStudio/releases) page are _unofficial_ and not maintained by us.**
>
> Installation support will not be given to users installing from unofficial sources. Use these versions at your own risk!
### Third-Party Dependencies
For video thumbnails and playback, you'll also need [FFmpeg](https://ffmpeg.org/download.html) installed on your system. If you encounter any issues with this, please reference our [FFmpeg Help](/docs/help/ffmpeg.md) guide.
## Usage
> [!TIP]
> For more usage instructions, see the [documentation site](https://docs.tagstud.io/libraries)!
### Creating/Opening a Library
@@ -122,50 +94,36 @@ With TagStudio opened, start by creating a new library or opening an existing on
### Refreshing the Library
Libraries under 10,000 files automatically scan for new or modified files when opened. In order to refresh the library manually, select "Refresh Directories" under the File menu.
### Adding Tags to File Entries
Access the "Add Tag" search box by either clicking on the "Add Tag" button at the bottom of the right sidebar, accessing the "Add Tags to Selected" option from the File menu, or by pressing <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd>.
From here you can search for existing tags or create a new one if the one you're looking for doesn't exist. Click the "+" button next to any tags you want to to the currently selected file entries. To quickly add the top result, press the <kbd>Enter</kbd>/<kbd>Return</kbd> key to add the the topmost tag and reset the tag search. Press <kbd>Enter</kbd>/<kbd>Return</kbd> once more to close the dialog box. By using this method, you can quickly add various tags in quick succession just by using the keyboard!
To remove a tag from a file entry, hover over the tag in the preview panel and click on the "-" icon that appears.
### Adding Metadata to File Entries
To add a metadata field to a file entry, start by clicking the "Add Field" button at the bottom of the preview panel. From the dropdown menu, select the type of metadata field youd like to add to the entry
### Editing Metadata Fields
#### Text Line / Text Box
Hover over the field and click the pencil icon. From there, add or edit text in the dialog box popup.
> [!WARNING]
> Keyboard control and navigation is currently _very_ buggy, but will be improved in future versions.
Libraries under 10,000 files automatically scan for new or modified files when opened. In order to refresh the library manually, select "Refresh Directories" under the File menu or by pressing <kbd>Ctrl</kbd></kbd>+<kbd>R</kbd> (macOS: <kbd>⌘ Command</kbd>+<kbd>R</kbd>).
### Creating Tags
Create a new tag by accessing the "New Tag" option from the Edit menu or by pressing <kbd>Ctrl</kbd>+<kbd>T</kbd>. In the tag creation panel, enter a tag name, optional shorthand name, optional tag aliases, optional parent tags, and an optional color.
- The tag **name** is the base name of the tag. **_This does NOT have to be unique!_**
- The tag **shorthand** is a special type of alias that displays in situations where screen space is more valuable, notably with name disambiguation.
- **Aliases** are alternate names for a tag. These let you search for terms other than the exact tag name in order to find the tag again.
- **Parent Tags** are tags in which this this tag can substitute for in searches. In other words, tags under this section are parents of this tag.
- Parent tags with the disambiguation check next to them will be used to help disambiguate tag names that may not be unique.
- For example: If you had a tag for "Freddy Fazbear", you might add "Five Nights at Freddy's" as one of the parent tags. If the disambiguation box is checked next to "Five Nights at Freddy's" parent tag, then the tag "Freddy Fazbear" will display as "Freddy Fazbear (Five Nights at Freddy's)". Furthermore, if the "Five Nights at Freddy's" tag has a shorthand like "FNAF", then the "Freddy Fazbear" tag will display as "Freddy Fazbear (FNAF)".
- The **color** option lets you select an optional color palette to use for your tag.
- The **"Is Category"** property lets you treat this tag as a category under which itself and any child tags inheriting from it will be sorted by inside the preview panel.
Create a new tag by accessing the "New Tag" option from the Edit menu or by pressing <kbd>Ctrl</kbd>+<kbd>T</kbd> (macOS: <kbd>⌘ Command</kbd>+<kbd>T</kbd>). In the tag creation panel, enter a tag name, optional shorthand name, optional tag aliases, optional parent tags, and an optional color.
#### Tag Manager
You can manage your library of tags from opening the "Tag Manager" panel from Edit -> "Tag Manager". From here you can create, search for, edit, and permanently delete any tags you've created in your library.
You can manage your library of tags from opening the "Tag Manager" panel from Edit -> "Tag Manager" or by pressing <kbd>Ctrl</kbd>+<kbd>M</kbd> (macOS: <kbd>⌘ Command</kbd>+<kbd>M</kbd>). From here you can create, search for, edit, and permanently delete any tags you've created in your library.
### Editing Tags
To edit a tag, click on it inside the preview panel or right-click the tag and select "Edit Tag" from the context menu.
### Adding Tags to File Entries
Access the "Add Tag" search box by either clicking on the "Add Tag" button at the bottom of the right sidebar, accessing the "Add Tags to Selected" option from the File menu, or by pressing <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd> (macOS: <kbd>⌘ Command</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd>).
From here you can search for existing tags or create a new one if the one you're looking for doesn't exist. Click the "+" button next to any tags you want to the currently selected file entries. To quickly add the top result, press the <kbd>Enter</kbd>/<kbd>Return</kbd> key to add the top-most tag and reset the tag search. Press <kbd>Enter</kbd>/<kbd>Return</kbd> once more to close the dialog box. By using this method, you can quickly add various tags in quick succession just by using the keyboard!
To remove a tag from a file entry, hover over the tag in the preview panel and click on the "-" icon that appears.
### Adding Fields to File Entries
To add a metadata field to a file entry, start by clicking the "Add Field" button at the bottom of the preview panel. From the dropdown menu, select the type of metadata field youd like to add to the entry
### Editing Fields
Hover over the field and click the pencil icon. From there, add or edit text in the dialog box popup.
### Relinking Moved Files
Inevitably some of the files inside your library will be renamed, moved, or deleted. If a file has been renamed or moved, TagStudio will display the thumbnail as a red broken chain link. To relink moved files or delete these entries, select the "Manage Unlinked Entries" option under the Tools menu. Click the "Refresh" button to scan your library for unlinked entries. Once complete, you can attempt to "Search & Relink" any unlinked file entries to their respective files, or "Delete Unlinked Entries" in the event the original files have been deleted and you no longer wish to keep their entries inside your library.
@@ -176,57 +134,101 @@ Inevitably some of the files inside your library will be renamed, moved, or dele
> [!WARNING]
> If multiple matches for a moved file are found (matches are currently defined as files with a matching filename as the original), TagStudio will currently ignore the match groups. Adding a GUI for manual selection, as well as smarter automated relinking, are high priorities for future versions.
### Saving the Library
See instructions in the "[Creating Development Environment](/CONTRIBUTING.md/#creating-a-development-environment)" section from the [contributing](https://docs.tagstud.io/contributing) page.
As of version 9.5, libraries are saved automatically as you go. To save a backup of your library, select File -> Save Library Backup from the menu bar.
## Installation
### Half-Implemented Features
To download executable builds of TagStudio, visit the [Releases](https://github.com/TagStudioDev/TagStudio/releases) page of the GitHub repository and download the latest release for your system under the "Assets" section at the bottom of the release.
These features were present in pre-public versions of TagStudio (9.0 and below) and have yet to be fully implemented.
TagStudio has builds for **Windows**, **macOS** _(Apple Silicon & Intel)_, and **Linux**. We also offer portable releases for Windows and Linux which are self-contained and easier to move around.
#### Fix Duplicate Files
For detailed instructions, installation help, and instructions for developing for TagStudio, please see the "[Installation](https://docs.tagstud.io/install)" page on our documentation website.
Load in a .dupeguru file generated by [dupeGuru](https://github.com/arsenetar/dupeguru/) and mirror metadata across entries marked as duplicates. After mirroring, return to dupeGuru to manage deletion of the duplicate files. After deletion, use the "Fix Unlinked Entries" feature in TagStudio to delete the duplicate set of entries for the now-deleted files
> [!IMPORTANT]
> If you're interested in contributing to TagStudio, please take a look at the [contribution guidelines](https://docs.tagstud.io/contributing) for how to get started!
### Third-Party Dependencies
For video thumbnails and playback, you'll also need [FFmpeg](https://ffmpeg.org/download.html) installed on your system. If you encounter any issues with this, please reference our [FFmpeg Help](/docs/help/ffmpeg.md) guide. For faster library scanning and refreshing, it's also recommended you install [ripgrep](https://github.com/BurntSushi/ripgrep).
<!-- prettier-ignore -->
> [!CAUTION]
> While this feature is functional, its a pretty roundabout process and can be streamlined in the future.
> **We do not currently publish TagStudio to any package managers. Any TagStudio distributions outside of the GitHub [Releases](https://github.com/TagStudioDev/TagStudio/releases) page are _unofficial_ and not maintained by us.**
>
> Installation support will not be given to users installing from unofficial sources. Use these versions at your own risk!
#### Macros
## Goals & Priorities
Apply tags and other metadata automatically depending on certain criteria. Set specific macros to run when the files are added to the library. Part of this includes applying tags automatically based on parent folders.
TagStudio aims to create an **open** and **robust** format for file tagging that isn't burdened by the limitations of traditional tagging and file metadata systems. **TagStudio** is the first proof-of-concept implementation of this system.
> [!CAUTION]
> Macro options are hardcoded, and theres currently no way for the user to interface with this (still incomplete) system at all.
See the [**Roadmap**](docs/roadmap.md) on the documentation site for a complete list of planned features and estimated timeline.
#### Gallery-dl Sidecar Importing
### Overall Goals
Import JSON sidecar data generated by [gallery-dl](https://github.com/mikf/gallery-dl).
- To achieve a portable, private, extensible, open-format, and feature-rich system of organizing and rediscovering files.
- To provide powerful methods for organization, notably the concept of tag inheritance, or "taggable tags" _(and in the near future, the combination of composition-based tags)._
- To create an implementation of such a system that is resilient against a users actions outside the program (modifying, moving, or renaming files) while also not burdening the user with mandatory sidecar files or requiring them to change their existing file structures and workflows.
- To support a wide range of users spanning across different platforms, multi-user setups, and those with large (several terabyte) libraries.
- To make the dang thing look nice, too. Its 2025, not 1995.
> [!CAUTION]
> This feature is not supported or documented in any official capacity whatsoever. It will likely be rolled-in to a larger and more generalized sidecar importing feature in the future.
### Project Priorities
## Launching/Building From Source
See instructions in the "[Creating Development Environment](/CONTRIBUTING.md/#creating-a-development-environment)" section from the [contribution documentation](/CONTRIBUTING.md).
1. **The concept.** Even if TagStudio as an application fails, Id hope that the idea lives on in a superior project. The goals outlined above dont reference TagStudio once - _TagStudio_ is what references the _goals._
2. **The system.** Frontends and implementations can vary, as they should. The core underlying metadata management system is what should be interoperable between different frontends, programs, and operating systems. A standard implementation for this should settle as development continues. This opens up the doors for improved and varied clients, integration with third-party applications, and more.
3. **The application.** If nothing else, TagStudio the application serves as the first (and so far only) implementation for this system of metadata management. This has the responsibility of doing the idea justice and showing just whats possible when it comes to user file management.
## FAQ
### What State Is the Project Currently In?
### Will TagStudio move, modify, or mess with my files?
As of writing (Alpha v9.5.0) the project is very usable, however there's some plenty of quirks and missing QoL features. Several additional features and changes are still planned (see: [Feature Roadmap](https://docs.tagstud.io/updates/roadmap/)) that add even more power and flexibility to the tagging and field systems while making it easier to tag in bulk and perform automated operations. Bugfixes and polish are constantly trickling in along with the larger feature releases.
**No**, outside of _explicit_ functionality such as "Move File(s) to Trash".
### What Features Are You Planning on Adding?
### Will TagStudio require me to recreate my tags or library in future updates?
See the [Feature Roadmap](https://docs.tagstud.io/updates/roadmap/) page for the core features being planned and implemented for TagStudio. For a more up to date look on what's currently being added for upcoming releases, see our GitHub [milestones](https://github.com/TagStudioDev/TagStudio/milestones) for versioned releases.
**No.** It's our highest priority to ensure that your data safely and smoothly transfers over to newer versions.
### Features That Will NOT Be Added
### What state is the project currently in?
As of writing (Alpha v9.5.5) the project is very usable, however there's still some quirks and missing QoL features. Several additional features and changes are still planned (see: [roadmap](https://docs.tagstud.io/roadmap)) that add even more power and flexibility to the tagging and field systems while making it easier to tag in bulk and perform automated operations. Bugfixes and polishes are constantly trickling in along with the larger feature releases.
### What features are you planning on adding?
See the [roadmap](https://docs.tagstud.io/roadmap) page for the core features being planned and implemented for TagStudio. For a more up to date look on what's currently being added for upcoming releases, see our GitHub [milestones](https://github.com/TagStudioDev/TagStudio/milestones) for versioned releases.
The most important remaining features before I consider the program to be "feature complete" are:
- Custom names for Fields
- List views for files
- Multiple root directory support for libraries
- Improved file entry relinking
- File entry groups
- Sorting by file date modified and created
- Macros
- Improved search bar with visualized tags and improved autocomplete
- Side panel for easier tagging (pinned tags, recent tags, tag search, tag palette)
- Improved tag management interface
- Improved and finalized Tag Categories
- Fixed and improved mixed entry data displays (see: [#337](https://github.com/TagStudioDev/TagStudio/issues/337))
- Sharable tag data
- Separate core library + API
### What features will NOT be added?
- Native Cloud Integration
- There are plenty of services already (native or third-party) that allow you to mount your cloud drives as virtual drives on your system. Hosting a TagStudio library on one of these mounts should function similarly to what native integration would look like.
- Supporting native cloud integrations such as these would be an unnecessary "reinventing the wheel" burden for us that is outside the scope of this project.
- Native ChatGPT/Non-Local LLM Integration
- This could mean different things depending on your intentions. Whether it's trying to use an LLM to replace the native search, or to trying to use a model for image recognition, I'm not interested in hooking people's TagStudio libraries into non-local LLMs such as ChatGPT and/or turn the program into a "chatbot" interface (see: [Goals/Privacy](#goals)). I wouldn't, however, mind using **locally** hosted models to provide the _optional_ ability for additional searching and tagging methods (especially when it comes to facial recognition) - but this would likely take the form of plugins external to the core program anyway.
- Native ChatGPT/Claude/Gemini/_Non-Local_ LLM Integration
- This could mean different things depending on your intentions. Whether it's trying to use an LLM to replace the native search, or to trying to use a model for image recognition, I'm not interested in hooking people's TagStudio libraries into non-local LLMs such as ChatGPT and/or turn the program into a "chatbot" interface (see: [Overall Goals/Privacy](#overall-goals)).
- With that being said, the future TagStudio API should be well-suited to connect to any sort of service you'd like, including machine learning models if so you choose. I just won't _personally_ add any native integrations with online services.
### Why Is this Already Version 9?
### Is a Rust port coming?
Over the first few years of private development the project went through several major iterations and rewrites. These major version bumps came quickly, and by the time TagStudio was opened-sourced the version number had already reached v9.0. Instead of resetting to "v0.0" or "v1.0" for this public release I decided to keep my v9.x numbering scheme and reserve v10.0 for when all the core features on the [Feature Roadmap](https://docs.tagstud.io/updates/roadmap/) are implemented. Ive also labeled this version as an "Alpha" and will drop this once either all of the core features are implemented or the project feels stable and feature-rich enough to be considered "Beta" and beyond.
Not from us, or at least _not quite_. There are plans to break off the core TagStudio library into its own MIT-licensed module that can be used in other applications and plugins, and ideally this would be written in Rust. While I understand there's a lot of vocal support and volunteers willing to help with this, it's something that's better off coming at my/our own pace in order to ensure it's done correctly to align with the project's intentions and to remain maintainable in the future.
### Windows Defender thinks TagStudio is a virus or a trojan, why?
Unfortunately, executable Python applications "compiled" with something like PyInstaller are notorious for raising false positives in anti-virus software, most commonly Windows Defender (see: [#276](https://github.com/TagStudioDev/TagStudio/issues/276) and related issues). There's really not much we can do about this on our end, as the malware matches frequently change and sample submissions to Microsoft are slow and often ineffective. If you're effected by this, you may need to allow TagStudio to bypass your anti-virus software.
### Why is TagStudio already on version 9.x?
Over the first few years of private development the project went through several major iterations and rewrites. These major version bumps came quickly, and by the time TagStudio was opened-sourced the version number had already reached v9.0. Instead of resetting to "v0.0" or "v1.0" for this public release I decided to keep my v9.x numbering scheme and reserve v10.0 for when all the core features on the [roadmap](https://docs.tagstud.io/roadmap/) are implemented. Ive also labeled this version as an "Alpha" and will drop this once either all of the core features are implemented or the project feels stable and feature-rich enough to be considered "Beta" and beyond.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -17,7 +17,7 @@ hide:
<figure markdown="span">
![TagStudio screenshot](./assets/screenshot.png){ width=80% }
<figcaption>TagStudio Alpha v9.5.0 running on macOS Sequoia.</figcaption>
<figcaption>TagStudio Alpha v9.5.5 running on macOS Sequoia.</figcaption>
</figure>
<div class="grid" markdown>

View File

@@ -2,520 +2,49 @@
icon: material/script-text
---
# :material-script-text: Macros
# :material-script-text: Tools & Macros
TagStudio features a configurable macro system which allows you to set up automatic or manually triggered actions to perform a wide array of operations on your [library](libraries.md). Each macro is stored in an individual script file and is created using [TOML](https://toml.io/en/) with a predefined schema described below. Macro files are stored in your library's "`.TagStudio/macros`" folder.
Tools and macros are features that serve to create a more fluid [library](libraries.md)-managing process, or provide some extra functionality. Please note that some are still in active development and will be fleshed out in future updates.
## Schema Version
## Tools
The `schema_version` key declares which version of the macro schema is currently being used. Current schema version: 1.
### Fix Unlinked Entries
```toml
schema_version = 1
```
This tool displays the number of unlinked [entries](entries.md), and some options for their resolution.
## Triggers
Refresh
: Scans through the library and updates the unlinked entry count.
The `triggers` key declares when a macro may be automatically ran. Macros can still be manually triggered even if they have automatic triggers defined.
Search & Relink
: Attempts to automatically find and reassign missing files.
- `on_open`: Run when the TagStudio library is opened.
- `on_refresh`: Run when the TagStudio library's directories have been refreshed.
- `on_new_entry`: Run a new [file entry](entries.md) that has been created.
Delete Unlinked Entries
: Displays a confirmation prompt containing the list of all missing files to be deleted before committing to or cancelling the operation.
```toml
triggers = ["on_new_entry"]
```
### Fix Duplicate Files
## Actions
This tool allows for management of duplicate files in the library using a [DupeGuru](https://dupeguru.voltaicideas.net/) file.
Actions are broad categories of operations that your macro will perform. They are represented by TOML tables and must have a unique name in your macro file, but the name itself has no importance to the macro. A single macro file can contain multiple actions and each action can contain multiple tasks.
Load DupeGuru File
: load the "results" file created from a DupeGuru scan
An action table with a name of your choosing (e.g. `[action]`) will contain the general configuration for your action, and nested task tables (e.g. `[action.task]`) will define the specifics of your action's tasks.
Mirror Entries
: Duplicate entries will have their contents mirrored across all instances. This allows for duplicate files to then be deleted with DupeGuru as desired, without losing the [field](fields.md) data that has been assigned to either. (Once deleted, the "Fix Unlinked Entries" tool can be used to clean up the duplicates)
Action tables must have an `action` key with one of the following valid action values:
### Create Collage
- [`import_data`](#import-data): Import data from a supported external source.
- [`add_data`](#add-data): Add data declared inside the macro file.
This tool is a preview of an upcoming feature. When selected, TagStudio will generate a collage of all the contents in a Library, which can be found in the Library folder ("/your-folder/.TagStudio/collages/"). Note that this feature is still in early development, and doesn't yet offer any customization options.
```toml
[newgrounds]
action = "import_data"
```
## Macros
Most of the configuration of actions comes at the [task configuration](#task-configuration) level. This is where you will build out exactly how your action will translate data and instructions into results for your TagStudio library.
### Auto-fill [WIP]
---
Tool is in development and will be documented in a future update.
### Add Data
### Sort fields
The `add_data` action lets you add data to a [file entry](entries.md) given one or more conditional statements. Unlike the [`import_data`](#import-data) action, the `add_data` action adds data declared in the macro itself rather than importing it form a source external to the macro.
Tool is in development. Will allow for user-defined sorting of [fields](fields.md).
Compatible Keys:
### Folders to Tags
- [`source_filters`](#source_filters)
- [`value`](#value)
---
### Import Data
The `import_data` action allows you to import external data into your TagStudio library in the form of [tags](tags.md) and [fields](fields.md). While some sources need explicit support (e.g. ID3, EXIF) generic sources such as JSON sidecar files can leverage a wide array of data shaping options that allow the underlying data structure to be abstracted from TagStudio's internal data structures. This macro pairs very well with tools that download sidecar files for data such as [gallery-dl](https://github.com/mikf/gallery-dl).
Compatible Keys:
- [`key`](#key)
- [`source_location`](#source_location)
- [`source_format`](#source_format)
- [`is_embedded`](#is_embedded)
If you're importing from an object-like source (e.g. JSON), you'll need to create a nested task table with the format `[action.task]` and provide a [`key`](#key) field filled with the name of the targeted source key. In this case the task name does not matter as long as it doesn't conflict with one of the built-in task names (i.e. "`map`", "`inverse_map`, "`template`").
<!-- prettier-ignore -->
=== "Importable JSON Data"
```json
{
"newgrounds": {
"tags": ["tag1", "tag2"]
}
}
```
=== "TOML Macro"
```toml
[newgrounds]
action="import_data"
[newgrounds.tags]
key="tags"
```
Inside the new table we can now declare additional information about the native data formats and how they should be imported into TagStudio.
---
### Action Configuration
#### `source_format`
<!-- prettier-ignore -->
!!! note ""
Compatible Actions: [`import_data`](#import-data)
The `source_format` key is used to declare what type of source data will be imported from.
```toml
[newgrounds]
action = "import_data"
source_format = "json"
```
- `exif`: Embedded EXIF metadata
- `id3`: Embedded ID3 metadata
- `json`: A JSON formatted file
- `text`: A plaintext file
- `xml`: An XML formatted file
- `xmp`: Embedded XMP metadata or an XMP sidecar file
---
#### `source_location`
<!-- prettier-ignore -->
!!! note ""
Compatible Actions: [`import_data`](#import-data)
The `source_location` key is used to declare where the metadata should be imported from. This can be a relative or absolute path, and can reference the targeted filename with the `{filename}` placeholder.
```toml
[newgrounds]
action = "import_data"
source_format = "json"
source_location = "{filename}.json" # Relative sidecar file
```
<!-- - `absolute`: An absolute file location
- `embedded`: Data that's embedded within the targeted file
- `sidecar`: A sidecar file with a relative file location -->
---
#### `is_embedded`
<!-- prettier-ignore -->
!!! note ""
Compatible Actions: [`import_data`](#import-data)
If targeting embedded data, add the `is_embedded` key and set it to `true`. If no `source_location` is used then the file this macro is targeting will be used as a source.
```toml
[newgrounds]
action = "import_data"
source_format = "id3"
is_embedded = true
```
---
#### `source_filters`
<!-- prettier-ignore -->
!!! note ""
Compatible Actions: [`add_data`](#add-data), [`import_data`](#import-data)
`source_filters` are used to declare a glob list of files that are able to be targeted by this action. An entry filepath only needs to fall under one of the given source filters in order for the macro to continue. If not, then the macro will be skipped for this file entry.
<!-- prettier-ignore -->
=== "import_data"
```toml
[newgrounds]
action = "import_data"
source_format = "json"
source_location = "{filename}.json"
source_filters = ["**/Newgrounds/**"]
```
=== "add_data"
```toml
[animated]
action = "add_data"
source_filters = ["**/*.gif", "**/*.apng"]
```
<!-- ### Source Types
The `source_type` key allows for the explicit declaration of the type and/or format of the source data. When this key is omitted, TagStudio will default to the data type that makes the most sense for the destination [TagStudio type](#tagstudio-types).
- `string`: A character string (text)
- `integer`: An integer
- `float`: A floating point number
- `url`: A string with a special URL formatting pass
- [`ISO8601`](https://en.wikipedia.org/wiki/ISO_8601) A standard datetime format
- `list:string`: List of strings (text)
- `list:integer`: List of integers
- `list:float`: List of floating point numbers -->
---
## Task Configuration
An [action's](#actions) tasks need to be configured using the built-in keys available to each action. These keys may be specific to certain actions, required or optional, or expect other specific formatting. The actions section will list each action's available keys, and the following list of keys will likewise list which actions they are compatible with along with any other rules.
Along with generally defining your own custom tasks, there are a few built-in tasks that have reserved names and offer extra functionality on top of your own tasks. These currently include:
- [`.inverse-map`](#many-to-1-inverse-map) (Inverse Tag Maps)
- [`.map`](#manual-tag-mapping) (Tag Maps)
- [`.template`](#templates) (Templates)
---
### `key`
<!-- prettier-ignore -->
!!! note ""
Compatible Actions: [`import_data`](#import-data)
The `key` key is used to specify the object key to target in your data source. If you're targeting a nested object, separate the names of the keys with a dot.
```toml
[artstation]
action = "import_data"
source_format = "json"
[artstation.tags]
key="tags"
ts_type = "tags"
[artstation.mediums]
key="mediums.name" # Nested key
ts_type = "tags"
```
When importing from the same key multiple times, you have the option to either choose different names for your task tables or use the same name with these tables wrapped in an extra pair of brackets.
<!-- prettier-ignore -->
=== "Single Import"
```toml
[newgrounds]
# Newgrounds table info here
[newgrounds.artist]
key="artist"
ts_type = "tags"
use_context = false
on_missing = "create"
```
=== "Multiple Imports"
```toml
[newgrounds]
# Newgrounds table info here
[newgrounds.artist_tag]
key="artist"
ts_type = "tags"
use_context = false
on_missing = "skip"
[newgrounds.artist_text]
key="artist"
ts_type = "text_line"
name = "Artist"
```
=== "Multiple Imports (Wrapped)"
```toml
[newgrounds]
# Newgrounds table info here
[[newgrounds.artist]]
key="artist"
ts_type = "tags"
use_context = false
on_missing = "skip"
[[newgrounds.artist]]
key="artist"
ts_type = "text_line"
name = "Artist"
```
---
### `ts_type`
<!-- prettier-ignore -->
!!! note ""
Compatible Actions: [`add_data`](#add-data), [`import_data`](#import-data)
The required `ts_type` key defines the destination data format inside TagStudio itself. This can be [tags](tags.md) or any [field](fields.md) type.
- [`tags`](tags.md)
- [`text_line`](fields.md#text-line)
- [`text_box`](fields.md#text-box)
- [`datetime`](fields.md#datetime)
<!-- prettier-ignore -->
=== "Title Field"
```toml
[newgrounds]
# newgrounds table info here
[newgrounds.title]
ts_type = "text_line"
name = "Title"
```
=== "Tags"
```toml
[newgrounds]
# newgrounds table info here
[newgrounds.tags]
ts_type = "tags"
```
#### Field Specific Keys
`name`: The name of the field to import into.
<!-- prettier-ignore -->
=== "text_line"
```toml
[newgrounds.user]
key="user"
ts_type = "text_line"
name = "Author"
```
=== "text_box"
```toml
[newgrounds.content]
key="content"
ts_type = "text_box"
name = "Description"
```
<!-- prettier-ignore -->
!!! note
As of writing (v9.5.3) TagStudio fields still do not allow for custom names. The macro system is designed to be forward-thinking with this feature in mind, however only existing TagStudio field names are currently considered valid. Any invalid field names will default to the "Notes" field.
#### Tag Specific Keys
Since TagStudio tags are more complex than other traditional tag formats, there are several options for fine-tuning how tags should be imported.
`delimiter`: The delimiter between string tags to use.
<!-- prettier-ignore -->
=== "Comma + Space Separation"
```toml
[newgrounds.tags]
ts_type = "tags"
delimiter = ", "
```
=== "Newline Separation"
```toml
[newgrounds.tags]
ts_type = "tags"
delimiter = "\n"
```
`on_missing`: Determines the behavior of how to react to source tags with no match in the library.
- `"prompt"`: Ask the user if they wish to create, skip, or manually choose an existing tag.
- `"create"`: Automatically create a new TagStudio tag based on the source tag.
- `"skip"` (Default): Ignore the unmatched tags.
```toml
[newgrounds.tags]
ts_type = "tags"
strict = false
use_context = true
on_missing = "create"
```
`prefix`: An optional prefix to remove.
<!-- prettier-ignore -->
!!! example
Given a list of tags such as `["#tag1", "#tag2", "#tag3"]`, you may wish to remove the "`#`" prefix.
```toml
[instagram.tags]
ts_type = "tags"
prefix = "#"
```
`strict`: A flag that determines what [names](tags.md#naming-tags) of the TagStudio tags should be used to compare against the source data when matching.
- `true`: Only match against the TagStudio tag [name](tags.md#name) field.
- `false` (Default): Match against any TagStudio tag name field including [shorthands](tags.md#shorthand), [aliases](tags.md#aliases), and the [disambiguation name](tags.md#disambiguation).
`use_context`: A flag that determines if TagStudio should use context clues from other source tags to provide more accurate tag matches.
- `true` (Default): Use context clue matching (slower, less ambiguous).
- `false`: Ignore surrounding source tags (faster, more ambiguous).
\*\*
---
### `value`
<!-- prettier-ignore -->
!!! note ""
Compatible Actions: [`add_data`](#add-data)
The `value` key is use specifically with the [`add_data`](#add-data) action to define what value should be added to the file entry.
<!-- prettier-ignore -->
=== "Title Field"
```toml
[animated]
action = "add_data"
source_filters = ["**/*.gif", "**/*.apng"]
[animated.title]
ts_type = "text_line"
name = "Title"
value = "Animated Image"
```
=== "Tags"
```toml
[animated]
action = "add_data"
source_filters = ["**/*.gif", "**/*.apng"]
[animated.tags]
ts_type = "tags"
value = ["Animated"]
```
---
### Manual Tag Mapping
If the automatic tag matching system isn't enough to import tags the way you'd like, you can manually specify mappings between source and destination tags. Tables with the `.map` or `.inverse_map` task suffixes will be used to map tags in the nearest scope.
<!-- prettier-ignore -->
=== "Global Scope"
```toml
# Applies to all actions in the macro file
[map]
```
=== "Action Scope"
```toml
# Applies to all tasks in the "newgrounds" action
[newgrounds.map]
```
=== "Key Scope"
```toml
# Only applies to the "ratings" task inside the "newgrounds" action
[newgrounds.ratings.map]
```
- `map`: Used for "[1 to 0](#1-to-0-ignore-matches)", "[1 to 1](#1-to-1)", and "[1 to many](#1-to-many)" mappings
- `inverse_map`: Used for "[many to 1](#many-to-1-inverse-map)" mappings
---
#### 1 to 0 (Ignore Matches)
By mapping the key of the source tag name to an empty string, you can ignore that tag when matching with your own tags. This is useful if you're importing from a source that uses tags you don't wish to use or create inside your own libraries.
```toml
[newgrounds.tags.map]
# Source Tag Name = Nothing, Ignore Matches
favorite = ""
```
---
#### 1 to 1
By mapping the key or quoted string of a source tag to one of your TagStudio tags, you can directly specify a destination tag while bypassing the matching algorithm.
<!-- prettier-ignore -->
!!! tip
Consider using tag [aliases](tags.md#aliases) instead of 1 to 1 mapping. This mapping technique is useful if you want to map a specific source tag to a destination tag that you otherwise don't consider to be an alternate name for the destination tag.
```toml
[newgrounds.tags.map]
# Source Tag Name = TagStudio Tag Name
colored_pencil = "Drawing"
"Colored Pencil" = "Drawing"
```
---
#### 1 to Many
By mapping the key or quoted string of a source tag to a **list of your TagStudio tags**, you can cause one source tag to import as more than one of your TagStudio tags.
```toml
[newgrounds.tags.map]
# Source Tag Name = List of TagStudio Tag Names
drawing = ["Drawing (2D)", "Image (Meta Tags)"]
video = ["Animation (2D)", "Animated (Meta Tags)"]
```
---
#### Many to 1 (Inverse Map)
By mapping the key or quoted string of one of your TagStudio tags to a **list of source tags**, you can declare a combination of required source tags that result in a wholly new matched TagStudio tag. This is useful if you use a single tag in your TagStudio library that is represented by multiple separate tags from your source.
```toml
[newgrounds.tags.inverse_map]
# TagStudio Tag Name = List of Source Tag Names
"Animation (2D)" = ["drawing", "video"]
"Animation (3D)" = ["3D", "video"]
```
---
### Templates
Templates are part of the `input_data` action and allow you to take data from one or more keys of a source and combine them into a single value. Template sub-action tables must begin with the action name and end with `.template` (e.g. `[action.template]`). Source object keys can be embedded in a string value if surrounded by curly braces (`{}`). Nested keys are accessed by separating the keys with a dot (e.g. `{key.nested_key}`).
<!-- prettier-ignore-start -->
=== "Composite Template"
```toml
[bluesky.template]
template = "https://www.bsky.app/profile/{author.handle}/post/{post_id}"
ts_type = "text_line"
name = "Source"
```
=== "Multiple Templates per Action"
```toml
[[artstation.template]]
template = "Original Tags: {tags}"
ts_type = "text_box"
name = "Notes"
[[artstation.template]]
template = "Original Mediums: {mediums}"
ts_type = "text_box"
name = "Notes"
```
<!-- prettier-ignore-end -->
Creates tags from the existing folder structure in the library, which are previewed in a hierarchy view for the user to confirm. A tag will be created for each folder and applied to all entries, with each subfolder being linked to the parent folder as a [parent tag](tags.md#parent-tags). Tags will initially be named after the folders, but can be fully edited and customized afterwards.

View File

@@ -61,7 +61,7 @@ Video thumbnails will default to the closest viable frame from the middle of the
### :material-sine-wave: Audio
Audio thumbnails will default to embedded cover art (if any) andfallback to generated waveform thumbnails. Audio file playback is supported in the Preview Panel if you have [FFmpeg](install.md#third-party-dependencies) installed on your system. Audio waveforms are currently not cached.
Audio thumbnails will default to embedded cover art (if any) and fallback to generated waveform thumbnails. Audio file playback is supported in the Preview Panel if you have [FFmpeg](install.md#third-party-dependencies) installed on your system. Audio waveforms are currently not cached.
| Filetype | Extensions | Dependencies |
| ------------------- | ------------------------ | :----------: |
@@ -69,7 +69,7 @@ Audio thumbnails will default to embedded cover art (if any) andfallback to gene
| AIFF | `.aiff`, `.aif`, `.aifc` | FFmpeg |
| Apple Lossless[^2] | `.alac`, `.aac` | FFmpeg |
| FLAC | `.flac` | FFmpeg |
| MP3 | `.mp3`, | FFmpeg |
| MP3 | `.mp3` | FFmpeg |
| Ogg | `.ogg` | FFmpeg |
| WAVE | `.wav`, `.wave` | FFmpeg |
| Windows Media Audio | `.wma` | FFmpeg |

View File

@@ -1,34 +0,0 @@
---
title: Entry Relinking
icon: material/link-variant
---
# :material-link-variant: Entry Relinking
### Fix Unlinked Entries
This tool displays the number of unlinked [entries](entries.md), and some options for their resolution.
Refresh
- Scans through the library and updates the unlinked entry count.
Search & Relink
- Attempts to automatically find and reassign missing files.
Delete Unlinked Entries
- Displays a confirmation prompt containing the list of all missing files to be deleted before committing to or cancelling the operation.
### Fix Duplicate Files
This tool allows for management of duplicate files in the library using a [DupeGuru](https://dupeguru.voltaicideas.net/) file.
Load DupeGuru File
- load the "results" file created from a DupeGuru scan
Mirror Entries
- Duplicate entries will have their contents mirrored across all instances. This allows for duplicate files to then be deleted with DupeGuru as desired, without losing the [field](fields.md) data that has been assigned to either. (Once deleted, the "Fix Unlinked Entries" tool can be used to clean up the duplicates)

View File

@@ -243,27 +243,18 @@ Discrete library objects representing [attributes](<https://en.wikipedia.org/wik
- [ ] OCR Search :material-chevron-up:{ .priority-low title="Low Priority" }
- [ ] Fuzzy Search :material-chevron-up:{ .priority-low title="Low Priority" }
### :material-script-text: [Macros](macros.md)
### :material-file-cog: [Macros](macros.md)
- [ ] Standard, Human Readable Format (TOML) :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.x]**
- [ ] Versioning System :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.x]**
- [ ] # Triggers **[v9.5.x]**
- [x] Standard, Human Readable Format (TOML) :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.5]**
- [x] Versioning System :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.5]**
- [ ] Triggers **[v9.5.5]**
- [ ] Triggers **[v9.5.x]**
- [ ] On File Added :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] On Library Refresh :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] [...]
- [ ] Actions **[v9.5.x]**
- [x] Import from JSON file :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Import from plaintext file :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Import from XML file :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [x] Create templated fields from other table keys :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [x] Remove tag prefixes from import sources :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [x] Specify tag delimiters from import sources :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [x] Add data (tags + fields) configured in macro :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [x] Glob filter for entry file :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [x] Map source tags to TagStudio tags :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Add Tag(s) :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Add Field(s) :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Set Field Content :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] [...]
### :material-table-arrow-right: Sharable Data
@@ -283,9 +274,9 @@ Packs are intended as an easy way to import and export specific data between lib
- [ ] UUIDs + Namespaces :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Standard, Human Readable Format (TOML) :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Versioning System :material-chevron-double-up:{ .priority-med title="Medium Priority" }
- [x] Macro Sharing :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.x]**
- [x] Importable :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [x] Exportable :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Macro Sharing :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v9.5.x]**
- [ ] Importable :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Exportable :material-chevron-triple-up:{ .priority-high title="High Priority" }
- [ ] Sharable Entry Data :material-chevron-double-up:{ .priority-med title="Medium Priority" } **[v9.9.x]**
- _Specifics of this are yet to be determined_
- [ ] Export Library to Human Readable Format :material-chevron-triple-up:{ .priority-high title="High Priority" } **[v10.0.0]**

12
flake.lock generated
View File

@@ -7,11 +7,11 @@
]
},
"locked": {
"lastModified": 1756770412,
"narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=",
"lastModified": 1763759067,
"narHash": "sha256-LlLt2Jo/gMNYAwOgdRQBrsRoOz7BPRkzvNaI/fzXi2Q=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "4524271976b625a4a605beefd893f270620fd751",
"rev": "2cccadc7357c0ba201788ae99c4dfa90728ef5e0",
"type": "github"
},
"original": {
@@ -22,11 +22,11 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1757487488,
"narHash": "sha256-zwE/e7CuPJUWKdvvTCB7iunV4E/+G0lKfv4kk/5Izdg=",
"lastModified": 1763835633,
"narHash": "sha256-HzxeGVID5MChuCPESuC0dlQL1/scDKu+MmzoVBJxulM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ab0f3607a6c7486ea22229b92ed2d355f1482ee0",
"rev": "050e09e091117c3d7328c7b2b7b577492c43c134",
"type": "github"
},
"original": {

View File

@@ -43,10 +43,8 @@ nav:
- entries.md
- preview-support.md
- search.md
- ignore.md
- macros.md
- Management:
- relinking.md
- ignore.md
- Fields:
- fields.md
- Tags:

View File

@@ -6,7 +6,7 @@
qt6,
ripgrep,
stdenv,
wrapGAppsHook,
wrapGAppsHook3,
pillow-jxl-plugin,
@@ -30,7 +30,7 @@ python3Packages.buildPythonApplication {
# Should be unnecessary once PR is pulled.
# PR: https://github.com/NixOS/nixpkgs/pull/271037
# Issue: https://github.com/NixOS/nixpkgs/issues/149812
wrapGAppsHook
wrapGAppsHook3
];
buildInputs = [
qt6.qtbase
@@ -70,7 +70,7 @@ python3Packages.buildPythonApplication {
"\${qtWrapperArgs[@]}"
];
pythonRemoveDeps = lib.optional (!withJXLSupport) [ "pillow_jxl" ];
pythonRemoveDeps = lib.optional (!withJXLSupport) "pillow_jxl";
pythonRelaxDeps = [
"numpy"
"pillow"
@@ -96,7 +96,6 @@ python3Packages.buildPythonApplication {
numpy
opencv-python
pillow
pillow-avif-plugin
pillow-heif
py7zr
pydantic

View File

@@ -51,7 +51,7 @@ let
# Should be unnecessary once PR is pulled.
# PR: https://github.com/NixOS/nixpkgs/pull/271037
# Issue: https://github.com/NixOS/nixpkgs/issues/149812
wrapGAppsHook
wrapGAppsHook3
];
buildInputs = with pkgs.qt6; [
qtbase
@@ -87,7 +87,7 @@ pkgs.mkShellNoCC {
env = {
QT_QPA_PLATFORM = "wayland;xcb";
UV_NO_SYNC = "1";
UV_NO_SYNC = 1;
UV_PYTHON_DOWNLOADS = "never";
};
@@ -111,7 +111,8 @@ pkgs.mkShellNoCC {
fi
source "''${venv}"/bin/activate
PYTHONPATH=${pythonPath}''${PYTHONPATH:+:}''${PYTHONPATH:-}
PYTHONPATH=${pythonPath}''${PYTHONPATH:+:''${PYTHONPATH}}
export PYTHONPATH
if [ ! -f "''${venv}"/pyproject.toml ] || ! diff --brief pyproject.toml "''${venv}"/pyproject.toml >/dev/null; then
printf '%s\n' 'Installing dependencies, pyproject.toml changed...' >&2

View File

@@ -5,7 +5,7 @@ build-backend = "hatchling.build"
[project]
name = "TagStudio"
description = "A User-Focused Photo & File Management System."
version = "9.5.5"
version = "9.5.6"
license = "GPL-3.0-only"
readme = "README.md"
requires-python = ">=3.12,<3.13"
@@ -16,8 +16,7 @@ dependencies = [
"mutagen~=1.47",
"numpy~=2.2",
"opencv_python~=4.11",
"Pillow>=10.2,<=11",
"pillow-avif-plugin~=1.5",
"Pillow>=10.2,<12",
"pillow-heif~=0.22",
"pillow-jxl-plugin~=1.3",
"py7zr==1.0.0",

View File

@@ -2,7 +2,7 @@
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
VERSION: str = "9.5.5" # Major.Minor.Patch
VERSION: str = "9.5.6" # Major.Minor.Patch
VERSION_BRANCH: str = "" # Usually "" or "Pre-Release"
# The folder & file names where TagStudio keeps its data relative to a library.
@@ -10,7 +10,6 @@ TS_FOLDER_NAME: str = ".TagStudio"
BACKUP_FOLDER_NAME: str = "backups"
COLLAGE_FOLDER_NAME: str = "collages"
IGNORE_NAME: str = ".ts_ignore"
MACROS_FOLDER_NAME: str = "macros"
THUMB_CACHE_NAME: str = "thumbs"
FONT_SAMPLE_TEXT: str = (

View File

@@ -51,6 +51,14 @@ class OpenStatus(enum.IntEnum):
CORRUPTED = 2
class MacroID(enum.Enum):
AUTOFILL = "autofill"
SIDECAR = "sidecar"
BUILD_URL = "build_url"
MATCH = "match"
CLEAN_URL = "clean_url"
class DefaultEnum(enum.Enum):
"""Allow saving multiple identical values in property called .default."""

View File

@@ -1062,21 +1062,19 @@ class Library:
selectinload(Tag.parent_tags),
selectinload(Tag.aliases),
)
if limit > 0:
query = query.limit(limit)
if name:
query = query.where(
or_(
Tag.name.istartswith(name),
Tag.shorthand.istartswith(name),
TagAlias.name.istartswith(name),
Tag.name.icontains(name),
Tag.shorthand.icontains(name),
TagAlias.name.icontains(name),
)
)
direct_tags = set(session.scalars(query))
ancestor_tag_ids: list[Tag] = []
for tag in direct_tags:
ancestor_tag_ids.extend(
@@ -1094,6 +1092,14 @@ class Library:
{at for at in ancestor_tags if at not in direct_tags},
]
logger.info(
"searching tags",
search=name,
limit=limit,
statement=str(query),
results=len(res),
)
session.expunge_all()
return res
@@ -1250,7 +1256,7 @@ class Library:
with Session(self.engine) as session:
return {x.key: x for x in session.scalars(select(ValueType)).all()}
def get_value_type(self, field_key: str | None) -> ValueType | None:
def get_value_type(self, field_key: str) -> ValueType:
with Session(self.engine) as session:
field = unwrap(session.scalar(select(ValueType).where(ValueType.key == field_key)))
session.expunge(field)
@@ -1263,7 +1269,6 @@ class Library:
field: ValueType | None = None,
field_id: FieldID | str | None = None,
value: str | datetime | None = None,
skip_on_exists: bool = False,
) -> bool:
logger.info(
"[Library][add_field_to_entry]",
@@ -1280,27 +1285,6 @@ class Library:
field_id = field_id.name
field = self.get_value_type(unwrap(field_id))
if not field:
logger.error(
"[Library] Could not add field to entry, invalid field type.", entry_id=entry_id
)
return False
if skip_on_exists:
entry = self.get_entry_full(entry_id, with_tags=False)
if not entry:
logger.exception("[Library] Entry does not exist", entry_id=entry_id)
return False
for field_ in entry.fields:
if field_.value == value and field_.type_key == field_id:
logger.info(
"[Library] Field value already exists for entry",
entry_id=entry_id,
value=value,
type=field_id,
)
return False
field_model: TextField | DatetimeField
if field.type in (FieldTypeEnum.TEXT_LINE, FieldTypeEnum.TEXT_BOX):
field_model = TextField(
@@ -1479,21 +1463,10 @@ class Library:
for tag_id in tag_ids_:
for entry_id in entry_ids_:
try:
logger.info(
"[Library][add_tags_to_entries] Adding tag to entry...",
tag_id=tag_id,
entry_id=entry_id,
)
session.add(TagEntry(tag_id=tag_id, entry_id=entry_id))
total_added += 1
session.commit()
except IntegrityError as e:
logger.warning(
"[Library][add_tags_to_entries] Tag already on entry",
warning=e,
tag_id=tag_id,
entry_id=entry_id,
)
except IntegrityError:
session.rollback()
return total_added
@@ -1590,7 +1563,6 @@ class Library:
return tag
# TODO: Fix and consolidate code with search_tags()
def get_tag_by_name(self, tag_name: str) -> Tag | None:
with Session(self.engine) as session:
statement = (

View File

@@ -146,7 +146,7 @@ class SQLBoolExpressionBuilder(BaseVisitor[ColumnElement[bool]]):
def __separate_tags(
self, terms: list[AST], only_single: bool = True
) -> tuple[list[int], list[ColumnElement[bool]]]:
tag_ids: list[int] = []
tag_ids: set[int] = set()
bool_expressions: list[ColumnElement[bool]] = []
for term in terms:
@@ -154,7 +154,7 @@ class SQLBoolExpressionBuilder(BaseVisitor[ColumnElement[bool]]):
match term.type:
case ConstraintType.TagID:
try:
tag_ids.append(int(term.value))
tag_ids.add(int(term.value))
except ValueError:
logger.error(
"[SQLBoolExpressionBuilder] Could not cast value to an int Tag ID",
@@ -164,10 +164,10 @@ class SQLBoolExpressionBuilder(BaseVisitor[ColumnElement[bool]]):
case ConstraintType.Tag:
ids = self.__get_tag_ids(term.value)
if not only_single:
tag_ids.extend(ids)
tag_ids.update(ids)
continue
elif len(ids) == 1:
tag_ids.append(ids[0])
tag_ids.add(ids[0])
continue
case ConstraintType.FileType:
pass
@@ -179,7 +179,7 @@ class SQLBoolExpressionBuilder(BaseVisitor[ColumnElement[bool]]):
raise NotImplementedError(f"Unhandled constraint: '{term.type}'")
bool_expressions.append(self.visit(term))
return tag_ids, bool_expressions
return list(tag_ids), bool_expressions
def __entry_has_all_tags(self, tag_ids: list[int]) -> ColumnElement[bool]:
"""Returns Binary Expression that is true if the Entry has all provided tag ids."""

View File

@@ -17,6 +17,7 @@ from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.core.library.ignore import PATH_GLOB_FLAGS, Ignore, ignore_to_glob
from tagstudio.core.utils.silent_subprocess import silent_run # pyright: ignore
from tagstudio.core.utils.types import unwrap
logger = structlog.get_logger(__name__)
@@ -30,24 +31,27 @@ class RefreshTracker:
def files_count(self) -> int:
return len(self.files_not_in_library)
def save_new_files(self):
def save_new_files(self) -> Iterator[int]:
"""Save the list of files that are not in the library."""
if self.files_not_in_library:
batch_size = 200
index = 0
while index < len(self.files_not_in_library):
yield index
end = min(len(self.files_not_in_library), index + batch_size)
entries = [
Entry(
path=entry_path,
folder=self.library.folder, # pyright: ignore[reportArgumentType]
folder=unwrap(self.library.folder),
fields=[],
date_added=dt.now(),
)
for entry_path in self.files_not_in_library
for entry_path in self.files_not_in_library[index:end]
]
self.library.add_entries(entries)
index = end
self.files_not_in_library = []
yield
def refresh_dir(self, library_dir: Path, force_internal_tools: bool = False) -> Iterator[int]:
"""Scan a directory for files, and add those relative filenames to internal variables.

View File

@@ -1,544 +0,0 @@
# Copyright (C) 2025 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
import json
from copy import deepcopy
from enum import StrEnum
from pathlib import Path
from typing import TYPE_CHECKING, Any, override
import structlog
import toml
from wcmatch import glob
from tagstudio.core.library.alchemy.fields import FieldID
if TYPE_CHECKING:
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Tag
logger = structlog.get_logger(__name__)
SCHEMA_VERSION = "schema_version"
TRIGGERS = "triggers"
ACTION = "action"
SOURCE_LOCATION = "source_location"
SOURCE_FILER = "source_filters"
SOURCE_FORMAT = "source_format"
FILENAME_PLACEHOLDER = "{filename}"
EXT_PLACEHOLDER = "{ext}"
TEMPLATE = "template"
KEY = "key"
SOURCE_TYPE = "source_type"
TS_TYPE = "ts_type"
NAME = "name"
VALUE = "value"
TAGS = "tags"
TEXT_LINE = "text_line"
TEXT_BOX = "text_box"
DATETIME = "datetime"
PREFIX = "prefix"
DELIMITER = "delimiter"
STRICT = "strict"
USE_CONTEXT = "use_context"
ON_MISSING = "on_missing"
JSON = "json"
XMP = "xmp"
EXIF = "exif"
ID3 = "id3"
MAP = "map"
INVERSE_MAP = "inverse_map"
class Actions(StrEnum):
IMPORT_DATA = "import_data"
ADD_DATA = "add_data"
class OnMissing(StrEnum):
PROMPT = "prompt"
CREATE = "create"
SKIP = "skip"
class Instruction:
def __init__(self) -> None:
pass
class AddFieldInstruction(Instruction):
def __init__(self, content, name: FieldID, field_type: str) -> None:
super().__init__()
self.content = content
self.name = name
self.type = field_type
@override
def __str__(self) -> str:
return str(self.content)
class AddTagInstruction(Instruction):
def __init__(
self,
tag_strings: list[str],
use_context: bool = True,
strict: bool = False,
on_missing: str = OnMissing.SKIP,
prefix: str = "",
) -> None:
super().__init__()
self.tag_strings = tag_strings
self.use_context = use_context
self.strict = strict
self.on_missing = on_missing
self.prefix = prefix
@override
def __str__(self) -> str:
return str(self.tag_strings)
def get_macro_name(
macro_path: Path,
) -> str:
"""Return the name of a macro, as read from the file.
Defaults to the filename if no name is declared or able to be read.
Args:
macro_path (Path): The full path of the macro file.
"""
name = macro_path.name
logger.info("[MacroParser] Parsing Macro for Name", macro_path=macro_path)
if not macro_path.exists():
logger.error("[MacroParser] Macro path does not exist", macro_path=macro_path)
return name
if not macro_path.exists():
logger.error("[MacroParser] Filepath does not exist", macro_path=macro_path)
return name
with open(macro_path) as f:
try:
macro = toml.load(f)
name = str(macro.get("name", name))
except toml.TomlDecodeError as e:
logger.error("[MacroParser] Could not parse macro", macro_path=macro_path, error=e)
logger.info("[MacroParser] Macro Name:", name=name, macro_path=macro_path)
return name
def parse_macro_file(
macro_path: Path,
filepath: Path,
) -> list[Instruction]:
"""Parse a macro file and return a list of actions for TagStudio to perform.
Args:
macro_path (Path): The full path of the macro file.
filepath (Path): The filepath associated with Entry being operated upon.
"""
results: list[Instruction] = []
logger.info("[MacroParser] Parsing Macro", macro_path=macro_path, filepath=filepath)
if not macro_path.exists():
logger.error("[MacroParser] Macro path does not exist", macro_path=macro_path)
return results
if not filepath.exists():
logger.error("[MacroParser] Filepath does not exist", filepath=filepath)
return results
with open(macro_path) as f:
try:
macro = toml.load(f)
except toml.TomlDecodeError as e:
logger.error("[MacroParser] Could not parse macro", macro_path=macro_path, error=e)
return results
logger.info(macro)
# Check Schema Version
schema_ver = macro.get(SCHEMA_VERSION, 0)
if not isinstance(schema_ver, int):
logger.error(
f"[MacroParser] Incorrect type for {SCHEMA_VERSION}, expected int",
schema_ver=schema_ver,
)
return results
if schema_ver != 1:
logger.error(f"[MacroParser] Unsupported Schema Version: {schema_ver}")
return results
logger.info(f"[MacroParser] Schema Version: {schema_ver}")
# Load Triggers
triggers = macro.get(TRIGGERS)
if triggers and not isinstance(triggers, list):
logger.error(
f"[MacroParser] Incorrect type for {TRIGGERS}, expected list", triggers=triggers
)
# Parse each action table
for table_key in macro:
if table_key in {SCHEMA_VERSION, TRIGGERS, NAME}:
continue
logger.info("[MacroParser] Parsing Table", table_key=table_key)
table: dict[str, Any] = macro[table_key]
logger.info(table.keys())
# TODO: Replace with table conditionals
source_filters: list[str] = table.get(SOURCE_FILER, [])
conditions_met: bool = False
if not source_filters:
conditions_met = True
else:
for filter_ in source_filters:
if glob.globmatch(filepath, filter_, flags=glob.GLOBSTAR):
logger.info(
f"[MacroParser] [{table_key}] "
f'{SOURCE_FILER}" Met filter requirement: {filter_}'
)
conditions_met = True
if not conditions_met:
logger.warning(
f"[MacroParser] [{table_key}] File didn't meet any path filter requirement",
filters=source_filters,
filepath=filepath,
)
continue
action: str = table.get(ACTION, "")
logger.info(f'[MacroParser] [{table_key}] "{ACTION}": {action}')
if action == Actions.IMPORT_DATA:
results.extend(_import_data(table, table_key, filepath))
elif action == Actions.ADD_DATA:
results.extend(_add_data(table))
logger.info(results)
return results
def _import_data(table: dict[str, Any], table_key: str, filepath: Path) -> list[Instruction]:
"""Process an import_data instruction and return a list of DataResults.
Importing data refers to importing data from a source external to TagStudio or any macro.
"""
results: list[Instruction] = []
source_format: str = str(table.get(SOURCE_FORMAT, ""))
if not source_format:
logger.error('[MacroParser] Parser Error: No "{SOURCE_FORMAT}" provided for table')
logger.info(f'[MacroParser] [{table_key}] "{SOURCE_FORMAT}": {source_format}')
raw_source_location = str(table.get(SOURCE_LOCATION, ""))
if FILENAME_PLACEHOLDER in raw_source_location:
# logger.info(f"[MacroParser] Filename placeholder detected: {raw_source_location}")
raw_source_location = raw_source_location.replace(FILENAME_PLACEHOLDER, str(filepath.stem))
if EXT_PLACEHOLDER in raw_source_location:
# logger.info(f"[MacroParser] File extension placeholder detected: {raw_source_location}")
# TODO: Make work with files that have multiple suffixes, like .tar.gz
raw_source_location = raw_source_location.replace(
EXT_PLACEHOLDER,
str(filepath.suffix)[1:], # Remove leading "."
)
if not raw_source_location.startswith(("/", "~")):
# The source location must be relative to the given filepath
source_location = filepath.parent / Path(raw_source_location)
else:
source_location = Path(raw_source_location)
logger.info(f'[MacroParser] [{table_key}] "{SOURCE_LOCATION}": {source_location}')
if not source_location.exists():
logger.error(
"[MacroParser] Sidecar filepath does not exist", source_location=source_location
)
return results
if source_format.lower() in JSON:
logger.info("[MacroParser] Parsing JSON sidecar file", sidecar_path=source_location)
with open(source_location, encoding="utf8") as f:
json_dump = json.load(f)
if not json_dump:
logger.warning("[MacroParser] Empty JSON sidecar file")
return results
logger.info(json_dump.items())
for table_key, table_value in table.items():
objects: list[dict[str, Any] | str] = []
content_value = ""
if isinstance(table_value, list):
objects = table_value
else:
objects.append(table_value)
for obj in objects:
if not isinstance(obj, dict):
continue
ts_type: str = str(obj.get(TS_TYPE, ""))
if not ts_type:
logger.warning(
f'[MacroParser] [{table_key}] No "{TS_TYPE}" key provided, skipping'
)
continue
json_key: str = str(obj.get(KEY, ""))
if json_key and json_key in json_dump:
json_value = json_dump.get(table_key)
logger.info(
f"[MacroParser] [{table_key}] Parsing JSON sidecar key",
key=table_key,
table_value=obj,
json_value=json_value,
)
content_value = json_value
if not json_value or isinstance(json_value, str) and not json_value.strip():
logger.warning(
f"[MacroParser] [{table_key}] Value for key was empty, skipping"
)
continue
elif table_key == TEMPLATE:
template: str = str(obj.get(TEMPLATE, ""))
logger.info(f"[MacroParser] [{table_key}] Filling template", template=template)
if not template:
logger.warning(f"[MacroParser] [{table_key}] Empty template, skipping")
continue
for k in json_dump:
template = _fill_template(template, json_dump, k)
logger.info(f"[MacroParser] [{table_key}] Template filled!", template=template)
content_value = template
else:
continue
# TODO: Determine if the source_type is even really ever needed
# source_type: str = str(tab_value.get(SOURCE_TYPE, ""))
str_name: str = str(obj.get(NAME, FieldID.NOTES.name))
name: FieldID = FieldID.NOTES
for fid in FieldID:
field_id = str_name.upper().replace(" ", "_")
if field_id == fid.name:
name = fid
continue
if ts_type == TAGS:
use_context: bool = bool(obj.get(USE_CONTEXT, False))
on_missing: str = str(obj.get(ON_MISSING, OnMissing.SKIP))
strict: bool = bool(obj.get(STRICT, False))
delimiter: str = ""
tag_strings: list[str] = []
# Tags are part of a single string
if isinstance(content_value, str):
delimiter = str(obj.get(DELIMITER, ""))
if delimiter:
# Split string based on given delimiter
tag_strings = content_value.split(delimiter)
else:
# If no delimiter is provided, assume the string is a single tag
tag_strings.append(content_value)
elif isinstance(content_value, bool):
tag_strings = [str(content_value)]
elif isinstance(content_value, list):
tag_strings = [str(v) for v in content_value] # pyright: ignore[reportUnknownVariableType]
else:
tag_strings = deepcopy([content_value])
# Remove a prefix (if given) from all tags strings (if any)
prefix = str(obj.get(PREFIX, ""))
if prefix:
tag_strings = [t.lstrip(prefix) for t in tag_strings]
# Swap any mapped tags for their new tag values
tag_map: dict[str, str] = obj.get(MAP, {})
mapped: list[str] = []
if tag_map:
for map_key, map_value in tag_map.items():
if map_key in tag_strings:
logger.info("[MacroParser] Mapping tag", old=map_key, new=map_value)
if isinstance(map_value, list):
mapped.extend(map_value)
else:
mapped.append(map_value)
tag_strings.remove(map_key)
tag_strings.extend(mapped)
tag_strings = [t.strip() for t in tag_strings if t.strip()]
logger.info("[MacroParser] Found tags", tag_strings=tag_strings)
results.append(
AddTagInstruction(
tag_strings=tag_strings,
use_context=use_context,
strict=strict,
on_missing=on_missing,
prefix="",
)
)
elif ts_type in (TEXT_LINE, TEXT_BOX, DATETIME):
results.append(
AddFieldInstruction(content=content_value, name=name, field_type=ts_type)
)
else:
logger.error('[MacroParser] [{table_key}] Unknown "{TS_TYPE}"', type=ts_type)
return results
def _add_data(table: dict[str, Any]) -> list[Instruction]:
"""Process an add_data instruction and return a list of DataResults.
Adding data refers to adding data defined inside a TagStudio macro, not from an external source.
"""
results: list[Instruction] = []
logger.error(table)
for table_value in table.values():
objects: list[dict[str, Any] | str] = []
if isinstance(table_value, list):
objects = table_value
else:
objects.append(table_value)
for obj in objects:
if not isinstance(obj, dict):
continue
ts_type = obj.get(TS_TYPE, "")
if ts_type == TAGS:
tag_strings: list[str] = obj.get(VALUE, [])
logger.error(tag_strings)
results.append(
AddTagInstruction(
tag_strings=tag_strings,
use_context=False,
)
)
elif ts_type in (TEXT_LINE, TEXT_BOX, DATETIME):
str_name: str = str(obj.get(NAME, FieldID.NOTES.name))
name: FieldID = FieldID.NOTES
for fid in FieldID:
field_id = str_name.upper().replace(" ", "_")
if field_id == fid.name:
name = fid
continue
content_value: str = str(obj.get(VALUE, ""))
results.append(
AddFieldInstruction(content=content_value, name=name, field_type=ts_type)
)
return results
def _fill_template(
template: str, table: dict[str, Any], table_key: str, template_key: str = ""
) -> str:
"""Replaces placeholder keys in a string with the value from that table.
Args:
template (str): The string containing placeholder keys.
Key names should be surrounded in curly braces. (e.g. "{key}").
Nested keys are accessed by separating the keys with a dot (e.g. "{key.nested_key}").
table (dict[str, Any]): The table to lookup values from.
table_key (str): The key to search for in the template and access the table with.
template_key (str): Similar to table_key, but is not used for accessing the table and
is instead used for representing the template key syntax for nested keys.
Used in recursive calls.
"""
key = template_key or table_key
value = table.get(table_key, "")
if isinstance(value, dict):
for v in value:
# NOTE: This f-string is the only thing defining how the nested key syntax works.
# If instead you wanted to use key[nested] syntax for example, use: f"{key}[{str(v)}]"
normalized_key: str = f"{key}.{str(v)}"
template = _fill_template(template, value, str(v), normalized_key)
value = str(value)
return template.replace(f"{{{key}}}", f"{value}")
def exec_instructions(library: "Library", entry_id: int, results: list[Instruction]) -> None:
for result in results:
if isinstance(result, AddTagInstruction):
_exec_add_tag(library, entry_id, result)
elif isinstance(result, AddFieldInstruction):
_exec_add_field(library, entry_id, result)
def _exec_add_tag(library: "Library", entry_id: int, result: AddTagInstruction):
tag_ids: set[int] = set()
for string in result.tag_strings:
if not string.strip():
continue
string = string.replace("_", " ")
base_and_parent = string.split("(")
parent = ""
base = base_and_parent[0].strip(" ")
parent_results: list[int] = []
if len(base_and_parent) > 1:
parent = base_and_parent[1].split(")")[0]
r: list[set[Tag]] = library.search_tags(name=parent, limit=-1)
if len(r) > 0:
parent_results = [t.id for t in r[0]]
# NOTE: The following code overlaps with update_tags() in tag_search.py
# Sort and prioritize the results
tag_results: list[set[Tag]] = library.search_tags(name=base, limit=-1)
results_0 = list(tag_results[0])
results_0.sort(key=lambda tag: tag.name.lower())
results_1 = list(tag_results[1])
results_1.sort(key=lambda tag: tag.name.lower())
raw_results = list(results_0 + results_1)
priority_results: set[Tag] = set()
for tag in raw_results:
if tag.name.lower().startswith(base.strip().lower()):
priority_results.add(tag)
all_results = sorted(list(priority_results), key=lambda tag: len(tag.name)) + [
r for r in raw_results if r not in priority_results
]
if parent and parent_results:
filtered_parents: list[Tag] = []
for tag in all_results:
for p_id in tag.parent_ids:
if p_id in parent_results:
filtered_parents.append(tag)
break
all_results = [t for t in all_results if t in filtered_parents]
final_tag: Tag | None = None
if len(all_results) > 0:
final_tag = all_results[0]
if final_tag:
tag_ids.add(final_tag.id)
if not tag_ids:
return
library.add_tags_to_entries(entry_id, tag_ids)
def _exec_add_field(library: "Library", entry_id: int, result: AddFieldInstruction):
library.add_field_to_entry(
entry_id, field_id=result.name, value=result.content, skip_on_exists=True
)

View File

@@ -0,0 +1,183 @@
# Copyright (C) 2024 Travis Abendshien (CyanVoxel).
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
"""The core classes and methods of TagStudio."""
import json
from pathlib import Path
import structlog
from tagstudio.core.constants import TS_FOLDER_NAME
from tagstudio.core.library.alchemy.fields import FieldID
from tagstudio.core.library.alchemy.library import Library
from tagstudio.core.library.alchemy.models import Entry
logger = structlog.get_logger(__name__)
class TagStudioCore:
def __init__(self):
self.lib: Library = Library()
@classmethod
def get_gdl_sidecar(cls, filepath: Path, source: str = "") -> dict:
"""Attempt to open and dump a Gallery-DL Sidecar file for the filepath.
Return a formatted object with notable values or an empty object if none is found.
"""
info = {}
_filepath = filepath.parent / (filepath.name + ".json")
# NOTE: This fixes an unknown (recent?) bug in Gallery-DL where Instagram sidecar
# files may be downloaded with indices starting at 1 rather than 0, unlike the posts.
# This may only occur with sidecar files that are downloaded separate from posts.
if source == "instagram" and not _filepath.is_file():
newstem = _filepath.stem[:-16] + "1" + _filepath.stem[-15:]
_filepath = _filepath.parent / (newstem + ".json")
logger.info("get_gdl_sidecar", filepath=filepath, source=source, sidecar=_filepath)
try:
with open(_filepath, encoding="utf8") as f:
json_dump = json.load(f)
if not json_dump:
return {}
if source == "twitter":
info[FieldID.DESCRIPTION] = json_dump["content"].strip()
info[FieldID.DATE_PUBLISHED] = json_dump["date"]
elif source == "instagram":
info[FieldID.DESCRIPTION] = json_dump["description"].strip()
info[FieldID.DATE_PUBLISHED] = json_dump["date"]
elif source == "artstation":
info[FieldID.TITLE] = json_dump["title"].strip()
info[FieldID.ARTIST] = json_dump["user"]["full_name"].strip()
info[FieldID.DESCRIPTION] = json_dump["description"].strip()
info[FieldID.TAGS] = json_dump["tags"]
# info["tags"] = [x for x in json_dump["mediums"]["name"]]
info[FieldID.DATE_PUBLISHED] = json_dump["date"]
elif source == "newgrounds":
# info["title"] = json_dump["title"]
# info["artist"] = json_dump["artist"]
# info["description"] = json_dump["description"]
info[FieldID.TAGS] = json_dump["tags"]
info[FieldID.DATE_PUBLISHED] = json_dump["date"]
info[FieldID.ARTIST] = json_dump["user"].strip()
info[FieldID.DESCRIPTION] = json_dump["description"].strip()
info[FieldID.SOURCE] = json_dump["post_url"].strip()
except Exception:
logger.exception("Error handling sidecar file.", path=_filepath)
return info
# def scrape(self, entry_id):
# entry = self.lib.get_entry(entry_id)
# if entry.fields:
# urls: list[str] = []
# if self.lib.get_field_index_in_entry(entry, 21):
# urls.extend([self.lib.get_field_attr(entry.fields[x], 'content')
# for x in self.lib.get_field_index_in_entry(entry, 21)])
# if self.lib.get_field_index_in_entry(entry, 3):
# urls.extend([self.lib.get_field_attr(entry.fields[x], 'content')
# for x in self.lib.get_field_index_in_entry(entry, 3)])
# # try:
# if urls:
# for url in urls:
# url = "https://" + url if 'https://' not in url else url
# html_doc = requests.get(url).text
# soup = bs(html_doc, "html.parser")
# print(soup)
# input()
# # except:
# # # print("Could not resolve URL.")
# # pass
@classmethod
def match_conditions(cls, lib: Library, entry_id: int) -> bool:
"""Match defined conditions against a file to add Entry data."""
# TODO - what even is this file format?
# TODO: Make this stored somewhere better instead of temporarily in this JSON file.
cond_file = lib.library_dir / TS_FOLDER_NAME / "conditions.json"
if not cond_file.is_file():
return False
entry: Entry = lib.get_entry(entry_id)
try:
with open(cond_file, encoding="utf8") as f:
json_dump = json.load(f)
for c in json_dump["conditions"]:
match: bool = False
for path_c in c["path_conditions"]:
if Path(path_c).is_relative_to(entry.path):
match = True
break
if not match:
return False
if not c.get("fields"):
return False
fields = c["fields"]
entry_field_types = {field.type_key: field for field in entry.fields}
for field in fields:
is_new = field["id"] not in entry_field_types
field_key = field["id"]
if is_new:
lib.add_field_to_entry(entry.id, field_key, field["value"])
else:
lib.update_entry_field(entry.id, field_key, field["value"])
except Exception:
logger.exception("Error matching conditions.", entry=entry)
return False
@classmethod
def build_url(cls, entry: Entry, source: str):
"""Try to rebuild a source URL given a specific filename structure."""
source = source.lower().replace("-", " ").replace("_", " ")
if "twitter" in source:
return cls._build_twitter_url(entry)
elif "instagram" in source:
return cls._build_instagram_url(entry)
@classmethod
def _build_twitter_url(cls, entry: Entry):
"""Build a Twitter URL given a specific filename structure.
Method expects filename to be formatted as 'USERNAME_TWEET-ID_INDEX_YEAR-MM-DD'
"""
try:
stubs = str(entry.path.name).rsplit("_", 3)
url = f"www.twitter.com/{stubs[0]}/status/{stubs[-3]}/photo/{stubs[-2]}"
return url
except Exception:
logger.exception("Error building Twitter URL.", entry=entry)
return ""
@classmethod
def _build_instagram_url(cls, entry: Entry):
"""Build an Instagram URL given a specific filename structure.
Method expects filename to be formatted as 'USERNAME_POST-ID_INDEX_YEAR-MM-DD'
"""
try:
stubs = str(entry.path.name).rsplit("_", 2)
# stubs[0] = stubs[0].replace(f"{author}_", '', 1)
# print(stubs)
# NOTE: Both Instagram usernames AND their ID can have underscores in them,
# so unless you have the exact username (which can change) on hand to remove,
# your other best bet is to hope that the ID is only 11 characters long, which
# seems to more or less be the case... for now...
url = f"www.instagram.com/p/{stubs[-3][-11:]}"
return url
except Exception:
logger.exception("Error building Instagram URL.", entry=entry)
return ""

View File

@@ -10,7 +10,7 @@ from datetime import datetime as dt
from warnings import catch_warnings
import structlog
from PySide6.QtCore import Qt, Signal
from PySide6.QtCore import Qt
from PySide6.QtGui import QGuiApplication
from PySide6.QtWidgets import (
QFrame,
@@ -22,7 +22,6 @@ from PySide6.QtWidgets import (
QWidget,
)
from tagstudio.core.constants import TAG_ARCHIVED, TAG_FAVORITE
from tagstudio.core.enums import Theme
from tagstudio.core.library.alchemy.enums import FieldTypeEnum
from tagstudio.core.library.alchemy.fields import (
@@ -51,9 +50,6 @@ logger = structlog.get_logger(__name__)
class FieldContainers(QWidget):
"""The Preview Panel Widget."""
favorite_updated = Signal(bool)
archived_updated = Signal(bool)
def __init__(self, library: Library, driver: "QtDriver"):
super().__init__()
@@ -131,7 +127,7 @@ class FieldContainers(QWidget):
container_index += 1
container_len += 1
if update_badges:
self.emit_badge_signals({t.id for t in entry_tags})
self.driver.emit_badge_signals({t.id for t in entry_tags})
# Write field container(s)
for index, field in enumerate(entry_fields, start=container_index):
@@ -242,7 +238,7 @@ class FieldContainers(QWidget):
self.driver.selected,
tag_ids=tags,
)
self.emit_badge_signals(tags, emit_on_absent=False)
self.driver.emit_badge_signals(tags, emit_on_absent=False)
def write_container(self, index: int, field: BaseField, is_mixed: bool = False):
"""Update/Create data for a FieldContainer.
@@ -493,16 +489,3 @@ class FieldContainers(QWidget):
result = remove_mb.exec_()
if result == QMessageBox.ButtonRole.ActionRole.value:
callback()
def emit_badge_signals(self, tag_ids: list[int] | set[int], emit_on_absent: bool = True):
"""Emit any connected signals for updating badge icons."""
logger.info("[emit_badge_signals] Emitting", tag_ids=tag_ids, emit_on_absent=emit_on_absent)
if TAG_ARCHIVED in tag_ids:
self.archived_updated.emit(True) # noqa: FBT003
elif emit_on_absent:
self.archived_updated.emit(False) # noqa: FBT003
if TAG_FAVORITE in tag_ids:
self.favorite_updated.emit(True) # noqa: FBT003
elif emit_on_absent:
self.favorite_updated.emit(False) # noqa: FBT003

View File

@@ -304,6 +304,7 @@ class TagSearchPanel(PanelWidget):
tag_widget.on_edit.disconnect()
tag_widget.on_remove.disconnect()
tag_widget.bg_button.clicked.disconnect()
tag_widget.search_for_tag_action.triggered.disconnect()
tag_id = tag.id
tag_widget.on_edit.connect(lambda t=tag: self.edit_tag(t))

View File

@@ -19,7 +19,6 @@ from xml.etree.ElementTree import Element
import cv2
import numpy as np
import pillow_avif # noqa: F401 # pyright: ignore[reportUnusedImport]
import py7zr
import py7zr.io
import rarfile

View File

@@ -23,7 +23,7 @@ LANGUAGES = {
"French": "fr",
"German": "de",
"Hungarian": "hu",
# "Italian": "it", # Minimal
"Italian": "it",
"Japanese": "ja",
"Norwegian Bokmål": "nb_NO",
"Polish": "pl",

View File

@@ -21,14 +21,12 @@ from pathlib import Path
from queue import Queue
from shutil import which
from typing import Generic, TypeVar
from unittest.mock import Mock
from warnings import catch_warnings
import structlog
from humanfriendly import format_size, format_timespan
from PySide6.QtCore import QObject, QSettings, Qt, QThread, QThreadPool, QTimer, Signal
from PySide6.QtGui import (
QAction,
QColor,
QDragEnterEvent,
QDragMoveEvent,
@@ -47,37 +45,29 @@ from PySide6.QtWidgets import (
QScrollArea,
)
# This import has side-effect of import PySide resources
import tagstudio.qt.resources_rc # noqa: F401 # pyright: ignore [reportUnusedImport]
from tagstudio.core.constants import (
MACROS_FOLDER_NAME,
TAG_ARCHIVED,
TAG_FAVORITE,
TS_FOLDER_NAME,
VERSION,
VERSION_BRANCH,
)
import tagstudio.qt.resources_rc # noqa: F401
from tagstudio.core.constants import TAG_ARCHIVED, TAG_FAVORITE, VERSION, VERSION_BRANCH
from tagstudio.core.driver import DriverMixin
from tagstudio.core.enums import SettingItems, ShowFilepathOption
from tagstudio.core.enums import MacroID, SettingItems, ShowFilepathOption
from tagstudio.core.library.alchemy.enums import (
BrowsingState,
FieldTypeEnum,
SortingModeEnum,
)
from tagstudio.core.library.alchemy.fields import FieldID
from tagstudio.core.library.alchemy.library import Library, LibraryStatus
from tagstudio.core.library.alchemy.models import Entry
from tagstudio.core.library.ignore import Ignore
from tagstudio.core.library.refresh import RefreshTracker
from tagstudio.core.macro_parser import (
Instruction,
exec_instructions,
get_macro_name,
parse_macro_file,
)
from tagstudio.core.media_types import MediaCategories
from tagstudio.core.query_lang.util import ParsingError
from tagstudio.core.ts_core import TagStudioCore
from tagstudio.core.utils.str_formatting import strip_web_protocol
from tagstudio.core.utils.types import unwrap
from tagstudio.qt.cache_manager import CacheManager
from tagstudio.qt.controllers.ffmpeg_missing_message_box import FfmpegMissingMessageBox
# this import has side-effect of import PySide resources
from tagstudio.qt.controllers.fix_ignored_modal_controller import FixIgnoredEntriesModal
from tagstudio.qt.controllers.ignore_modal_controller import IgnoreModal
from tagstudio.qt.controllers.library_info_window_controller import LibraryInfoWindow
@@ -106,7 +96,6 @@ from tagstudio.qt.resource_manager import ResourceManager
from tagstudio.qt.translations import Translations
from tagstudio.qt.utils.custom_runnable import CustomRunnable
from tagstudio.qt.utils.file_deleter import delete_file
from tagstudio.qt.utils.file_opener import open_file
from tagstudio.qt.utils.function_iterator import FunctionIterator
from tagstudio.qt.views.main_window import MainWindow
from tagstudio.qt.views.panel_modal import PanelModal
@@ -188,6 +177,9 @@ class QtDriver(DriverMixin, QObject):
SIGTERM = Signal()
favorite_updated = Signal(bool)
archived_updated = Signal(bool)
tag_manager_panel: PanelModal | None = None
color_manager_panel: TagColorManager | None = None
ignore_modal: PanelModal | None = None
@@ -319,20 +311,10 @@ class QtDriver(DriverMixin, QObject):
pal: QPalette = self.app.palette()
pal.setColor(QPalette.ColorGroup.Normal, QPalette.ColorRole.Window, QColor("#1e1e1e"))
pal.setColor(QPalette.ColorGroup.Normal, QPalette.ColorRole.Button, QColor("#1e1e1e"))
pal.setColor(QPalette.ColorGroup.Inactive, QPalette.ColorRole.Window, QColor("#232323"))
pal.setColor(QPalette.ColorGroup.Inactive, QPalette.ColorRole.Button, QColor("#232323"))
pal.setColor(
QPalette.ColorGroup.Inactive,
QPalette.ColorRole.Window,
QColor("#232323"),
)
pal.setColor(
QPalette.ColorGroup.Inactive,
QPalette.ColorRole.Button,
QColor("#232323"),
)
pal.setColor(
QPalette.ColorGroup.Inactive,
QPalette.ColorRole.ButtonText,
QColor("#666666"),
QPalette.ColorGroup.Inactive, QPalette.ColorRole.ButtonText, QColor("#666666")
)
self.app.setPalette(pal)
@@ -378,8 +360,9 @@ class QtDriver(DriverMixin, QObject):
self.tag_manager_panel = PanelModal(
widget=TagDatabasePanel(self, self.lib),
title=Translations["tag_manager.title"],
done_callback=lambda checked=False,
s=self.selected: self.main_window.preview_panel.set_selection(s, update_preview=False),
done_callback=lambda checked=False: (
self.main_window.preview_panel.set_selection(self.selected, update_preview=False)
),
has_save=False,
)
@@ -390,9 +373,9 @@ class QtDriver(DriverMixin, QObject):
self.add_tag_modal = TagSearchModal(self.lib, is_tag_chooser=True)
self.add_tag_modal.tsp.set_driver(self)
self.add_tag_modal.tsp.tag_chosen.connect(
lambda t, s=self.selected: (
self.add_tags_to_selected_callback(t),
self.main_window.preview_panel.set_selection(s),
lambda chosen_tag: (
self.add_tags_to_selected_callback([chosen_tag]),
self.main_window.preview_panel.set_selection(self.selected),
)
)
@@ -555,8 +538,6 @@ class QtDriver(DriverMixin, QObject):
# endregion
# region Macros Menu ==========================================================
self.main_window.menu_bar.macros_menu.aboutToShow.connect(self.update_macros_menu)
def create_folders_tags_modal():
if not hasattr(self, "folders_modal"):
self.folders_modal = FoldersToTagsModal(self.lib, self)
@@ -578,14 +559,16 @@ class QtDriver(DriverMixin, QObject):
# endregion
# endregion
self.main_window.search_field.textChanged.connect(self.update_completions_list)
self.main_window.preview_panel.field_containers_widget.archived_updated.connect(
self.archived_updated.connect(
lambda hidden: self.update_badges(
{BadgeType.ARCHIVED: hidden}, origin_id=0, add_tags=False
)
)
self.main_window.preview_panel.field_containers_widget.favorite_updated.connect(
self.favorite_updated.connect(
lambda hidden: self.update_badges(
{BadgeType.FAVORITE: hidden}, origin_id=0, add_tags=False
)
@@ -769,7 +752,6 @@ class QtDriver(DriverMixin, QObject):
self.set_clipboard_menu_viability()
self.set_select_actions_visibility()
self.update_macros_menu(clear=True)
if hasattr(self, "library_info_window"):
self.library_info_window.close()
@@ -804,8 +786,7 @@ class QtDriver(DriverMixin, QObject):
end_time = time.time()
self.main_window.status_bar.showMessage(
Translations.format(
"status.library_closed",
time_span=format_timespan(end_time - start_time),
"status.library_closed", time_span=format_timespan(end_time - start_time)
)
)
@@ -823,6 +804,19 @@ class QtDriver(DriverMixin, QObject):
)
)
def emit_badge_signals(self, tag_ids: list[int] | set[int], emit_on_absent: bool = True):
"""Emit any connected signals for updating badge icons."""
logger.info("[emit_badge_signals] Emitting", tag_ids=tag_ids, emit_on_absent=emit_on_absent)
if TAG_ARCHIVED in tag_ids:
self.archived_updated.emit(True) # noqa: FBT003
elif emit_on_absent:
self.archived_updated.emit(False) # noqa: FBT003
if TAG_FAVORITE in tag_ids:
self.favorite_updated.emit(True) # noqa: FBT003
elif emit_on_absent:
self.favorite_updated.emit(False) # noqa: FBT003
def add_tag_action_callback(self):
panel = BuildTagPanel(self.lib)
self.modal = PanelModal(
@@ -871,9 +865,10 @@ class QtDriver(DriverMixin, QObject):
self.main_window.preview_panel.set_selection(self.selected)
def add_tags_to_selected_callback(self, tag_ids: list[int]):
selected = self.selected
selected: list[int] = self.selected
self.main_window.thumb_layout.add_tags(selected, tag_ids)
self.lib.add_tags_to_entries(selected, tag_ids)
self.emit_badge_signals(tag_ids)
def delete_files_callback(self, origin_path: str | Path, origin_id: int | None = None):
"""Callback to send on or more files to the system trash.
@@ -1071,7 +1066,7 @@ class QtDriver(DriverMixin, QObject):
pw.show()
iterator.value.connect(
lambda: (
lambda _count: (
pw.update_label(
Translations.format(
"entries.running.dialog.new_entries", total=f"{files_count:n}"
@@ -1098,42 +1093,56 @@ class QtDriver(DriverMixin, QObject):
# # self.run_macro('autofill', id)
yield 0
def run_macros(self, macro_name: str, entry_ids: list[int]):
"""Run a Macro on a list of entires."""
def run_macros(self, name: MacroID, entry_ids: list[int]):
"""Run a specific Macro on a group of given entry_ids."""
for entry_id in entry_ids:
self.run_macro(macro_name, entry_id)
self.main_window.preview_panel.refresh_selection(update_preview=False)
def run_macro(self, macro_name: str, entry_id: int):
"""Run a Macro on a single entry."""
if not self.lib.library_dir:
logger.error("[QtDriver] Can't run macro when no library is open!")
return
entry: Entry | None = self.lib.get_entry(entry_id)
if not entry:
logger.error(f"[QtDriver] No Entry given ID {entry_id}!")
return
self.run_macro(name, entry_id)
def run_macro(self, name: MacroID, entry_id: int):
"""Run a specific Macro on an Entry given a Macro name."""
entry: Entry = self.lib.get_entry(entry_id)
full_path = self.lib.library_dir / entry.path
# macro_path = Path(
# self.lib.library_dir / TS_FOLDER_NAME / MACROS_FOLDER_NAME / f"{macro_name}.toml"
# )
macro_path = Path(self.lib.library_dir / TS_FOLDER_NAME / MACROS_FOLDER_NAME / macro_name)
source = "" if entry.path.parent == Path(".") else entry.path.parts[0].lower()
logger.info(
"[QtDriver] Running Macro",
macro_path=macro_name,
"running macro",
source=source,
macro=name,
entry_id=entry.id,
grid_idx=entry_id,
)
results: list[Instruction] = parse_macro_file(macro_path, full_path)
exec_instructions(self.lib, entry_id, results)
if name == MacroID.AUTOFILL:
for macro_id in MacroID:
if macro_id == MacroID.AUTOFILL:
continue
self.run_macro(macro_id, entry_id)
@property
def sorting_direction(self) -> bool:
"""Whether to Sort the results in ascending order."""
return self.main_window.sorting_direction_combobox.currentData()
elif name == MacroID.SIDECAR:
parsed_items = TagStudioCore.get_gdl_sidecar(full_path, source)
for field_id, value in parsed_items.items():
if isinstance(value, list) and len(value) > 0 and isinstance(value[0], str):
value = self.lib.tag_from_strings(value)
self.lib.add_field_to_entry(
entry.id,
field_id=field_id,
value=value,
)
elif name == MacroID.BUILD_URL:
url = TagStudioCore.build_url(entry, source)
if url is not None:
self.lib.add_field_to_entry(entry.id, field_id=FieldID.SOURCE, value=url)
elif name == MacroID.MATCH:
TagStudioCore.match_conditions(self.lib, entry.id)
elif name == MacroID.CLEAN_URL:
for field in entry.text_fields:
if field.type.type == FieldTypeEnum.TEXT_LINE and field.value:
self.lib.update_entry_field(
entry_ids=entry.id,
field=field,
content=strip_web_protocol(field.value),
)
def sorting_direction_callback(self):
logger.info("Sorting Direction Changed", ascending=self.main_window.sorting_direction)
@@ -1257,12 +1266,6 @@ class QtDriver(DriverMixin, QObject):
self.main_window.preview_panel.set_selection(self.selected)
# TODO: Remove?
def set_macro_menu_viability(self):
# for action in self.macros_menu.actions():
# action.setDisabled(not self.selected)
pass
def set_clipboard_menu_viability(self):
if len(self.selected) == 1:
self.main_window.menu_bar.copy_fields_action.setEnabled(True)
@@ -1295,8 +1298,7 @@ class QtDriver(DriverMixin, QObject):
def update_completions_list(self, text: str) -> None:
matches = re.search(
r"((?:.* )?)(mediatype|filetype|path|tag|tag_id):(\"?[A-Za-z0-9\ \t]+\"?)?",
text,
r"((?:.* )?)(mediatype|filetype|path|tag|tag_id):(\"?[A-Za-z0-9\ \t]+\"?)?", text
)
completion_list: list[str] = []
@@ -1535,53 +1537,6 @@ class QtDriver(DriverMixin, QObject):
self.cached_values.sync()
self.update_recent_lib_menu()
def update_macros_menu(self, clear: bool = False):
if not self.main_window.menu_bar.macros_menu or isinstance(
self.main_window.menu_bar.macros_menu, Mock
): # NOTE: Needed for tests?
return
# Create actions for each macro
actions: list[QAction] = []
if self.lib.library_dir and not clear:
macros_path = self.lib.library_dir / TS_FOLDER_NAME / MACROS_FOLDER_NAME
for f in macros_path.glob("*"):
logger.info(f)
if f.suffix != ".toml" or f.is_dir() or f.name.startswith("._"):
continue
action = QAction(
get_macro_name(f), self.main_window.menu_bar.macros_menu.parentWidget()
)
action.triggered.connect(
lambda checked=False, name=f.name: (self.run_macros(name, self.selected)),
)
actions.append(action)
open_folder = QAction("Open Macros Folder...", self.main_window.menu_bar.macros_menu)
open_folder.triggered.connect(self.open_macros_folder)
actions.append(open_folder)
if clear:
open_folder.setEnabled(False)
# Clear previous actions
for action in self.main_window.menu_bar.macros_menu.actions():
self.main_window.menu_bar.macros_menu.removeAction(action)
# Add new actions
for action in actions:
self.main_window.menu_bar.macros_menu.addAction(action)
self.main_window.menu_bar.macros_menu.addSeparator()
self.main_window.menu_bar.macros_menu.addAction(open_folder)
def open_macros_folder(self):
if not self.lib.library_dir:
return
path = self.lib.library_dir / TS_FOLDER_NAME / MACROS_FOLDER_NAME
path.mkdir(exist_ok=True)
open_file(path, file_manager=True, is_dir=True)
def open_settings_modal(self):
SettingsPanel.build_modal(self).show()
@@ -1614,10 +1569,7 @@ class QtDriver(DriverMixin, QObject):
except Exception as e:
logger.error(e)
open_status = LibraryStatus(
success=False,
library_path=path,
message=type(e).__name__,
msg_description=str(e),
success=False, library_path=path, message=type(e).__name__, msg_description=str(e)
)
self.cache_manager = CacheManager(
path,
@@ -1664,7 +1616,6 @@ class QtDriver(DriverMixin, QObject):
library_dir_display = self.lib.library_dir.name
self.update_libs_list(path)
self.update_macros_menu()
self.main_window.setWindowTitle(
Translations.format(
"app.title",
@@ -1691,7 +1642,7 @@ class QtDriver(DriverMixin, QObject):
self.main_window.menu_bar.folders_to_tags_action.setEnabled(True)
self.main_window.menu_bar.library_info_action.setEnabled(True)
self.main_window.preview_panel.set_selection()
self.main_window.preview_panel.set_selection(self.selected)
# page (re)rendering, extract eventually
initial_state = BrowsingState(

View File

@@ -20,19 +20,13 @@ from tagstudio.core.utils.types import unwrap
logger = structlog.get_logger(__name__)
def open_file(
path: str | Path,
file_manager: bool = False,
is_dir: bool = False,
windows_start_command: bool = False,
):
def open_file(path: str | Path, file_manager: bool = False, windows_start_command: bool = False):
"""Open a file in the default application or file explorer.
Args:
path (str): The path to the file to open.
file_manager (bool, optional): Whether to open the file in the file manager
(e.g. Finder on macOS). Defaults to False.
is_dir (bool): True if the path points towards a directory, false if a file.
windows_start_command (bool): Flag to determine if the older 'start' command should be used
on Windows for opening files. This fixes issues on some systems in niche cases.
"""
@@ -83,7 +77,7 @@ def open_file(
if sys.platform == "darwin":
command_name = "open"
command_args = [str(path)]
if file_manager and not is_dir:
if file_manager:
# will reveal in Finder
command_args.append("-R")
else:

View File

@@ -64,7 +64,6 @@ class PreviewPanelView(QWidget):
super().__init__()
self.lib = library
self._selected = []
self.__thumb = PreviewThumb(self.lib, driver)
self.__file_attrs = FileAttributes(self.lib, driver)
self._fields = FieldContainers(
@@ -133,11 +132,7 @@ class PreviewPanelView(QWidget):
def _set_selection_callback(self):
raise NotImplementedError()
def refresh_selection(self, update_preview: bool = True):
"""Refresh the panel's widgets to use current library data."""
self.set_selection(self._selected, update_preview)
def set_selection(self, selected: list[int] | None = None, update_preview: bool = True):
def set_selection(self, selected: list[int], update_preview: bool = True):
"""Render the panel widgets with the newest data from the Library.
Args:
@@ -145,10 +140,10 @@ class PreviewPanelView(QWidget):
update_preview (bool): Should the file preview be updated?
(Only works with one or more items selected)
"""
self._selected = selected or []
self._selected = selected
try:
# No Items Selected
if len(self._selected) == 0:
if len(selected) == 0:
self.__thumb.hide_preview()
self.__file_attrs.update_stats()
self.__file_attrs.update_date_label()
@@ -157,8 +152,8 @@ class PreviewPanelView(QWidget):
self.add_buttons_enabled = False
# One Item Selected
elif len(self._selected) == 1:
entry_id = self._selected[0]
elif len(selected) == 1:
entry_id = selected[0]
entry: Entry = unwrap(self.lib.get_entry(entry_id))
filepath: Path = unwrap(self.lib.library_dir) / entry.path
@@ -174,10 +169,10 @@ class PreviewPanelView(QWidget):
self.add_buttons_enabled = True
# Multiple Selected Items
elif len(self._selected) > 1:
elif len(selected) > 1:
# items: list[Entry] = [self.lib.get_entry_full(x) for x in self.driver.selected]
self.__thumb.hide_preview() # TODO: Render mixed selection
self.__file_attrs.update_multi_selection(len(self._selected))
self.__file_attrs.update_multi_selection(len(selected))
self.__file_attrs.update_date_label()
self._fields.hide_containers() # TODO: Allow for mixed editing

View File

@@ -1,13 +1,354 @@
{
"about.config_path": "Percorso di Configurazione",
"about.description": "TagStudio è un'applicazione di organizzazione dei file e delle foto che utlizza un sistema di etichette focalizzato sul dare libertà e flessibilità all'utente. Niente programmi o formati proprietari, niente mare di file sidecar, e nessun stravolgimento della struttura del tuo sistema di file.",
"about.documentation": "Documentazione",
"about.license": "Licenza",
"about.module.found": "Trovato",
"about.title": "Informazioni su TagStudio",
"about.website": "Sito web",
"app.git": "Git Commit",
"app.pre_release": "Pre-rilascio",
"app.title": "{base_title} - Biblioteca '{library_dir}'",
"color.color_border": "Usa Colore Secondario per il Bordo",
"color.confirm_delete": "Sei sicuro di voler eliminare il colore \"{color_name}\"?",
"color.delete": "Elimina Etichetta",
"color.import_pack": "Importa Pacchetto di Colori",
"color.name": "Nome",
"color.namespace.delete.prompt": "Sei sicuro di voler eliminare questo spazio dei nomi dei colori? Questo eliminerà TUTTI i colori contenuti nello spazio dei nomi insieme ad esso!",
"color.namespace.delete.title": "Elimina Spazio dei Nomi dei Colori",
"color.new": "Nuovo Colore",
"color.placeholder": "Colore",
"color.primary": "Colore Primario",
"color.primary_required": "Colore Primario (Obbligatorio)",
"color.secondary": "Colore Secondario",
"color.title.no_color": "Nessun Colore",
"color_manager.title": "Gestisci Colori dei Tag",
"dependency.missing.title": "{dependency} Non Trovata",
"drop_import.description": "I seguenti file corrispondono a percorsi di file che già esistono nella biblioteca",
"drop_import.duplicates_choice.plural": "I seguenti {count} file corrispondono a percorsi di file già esistenti nella biblioteca.",
"drop_import.duplicates_choice.singular": "Il seguente file corrisponde ad un percorso di file già esistente nella biblioteca.",
"drop_import.progress.label.initial": "Importando Nuovi File...",
"drop_import.progress.label.plural": "Importando Nuovi File...\n{count} File Importati.{suffix}",
"drop_import.progress.label.singular": "Importando Nuovi File...\n1 File Importato.{suffix}",
"drop_import.progress.window_title": "Importa File",
"drop_import.title": "File in Conflitto",
"edit.color_manager": "Gestisci i Colori delle Etichette",
"edit.copy_fields": "Copia Campi",
"edit.paste_fields": "Incolla Campi",
"edit.tag_manager": "Gestisci Etichette",
"entries.duplicate.merge": "Unisci Voci Duplicate",
"entries.duplicate.merge.label": "Unendo Voci Duplicate...",
"entries.duplicate.refresh": "Ricarica Voci Duplicate",
"entries.duplicates.description": "Le voci duplicate sono definite come molteplici voci che puntano allo stesso file sul disco. Unendole verranno combinate le etichette ed i metadati da tutti i duplicati in una singola voce consolidata. Quese non devono essere confuse con i \"file duplicati\", che sono duplicati dei tuoi file stessi al di fuori di TagStudio.",
"entries.generic.refresh_alt": "&Ricarica",
"entries.generic.remove.removing": "Rimuovendo Voci",
"entries.generic.remove.removing_count": "Rimozione di {count} Voci...",
"entries.ignored.description": "Le voci dei file sono considerare \"ignorate\" se sono state aggiunte alla biblioteca prima che le regole di ignoranza dell'utente (attraverso il file '.ts_ignore') siano state aggiornate per escluderle. I file ignorati sono tenuti nella biblioteca, per impostazione predefinita, per prevenire perdite accidentali di dati durante l'aggiornamento delle regole di ignoranza.",
"entries.ignored.ignored_count": "Voci Ignorate: {count}",
"entries.ignored.remove": "Rimuovi Voci Ignorate",
"entries.ignored.remove_alt": "Rimuo&vi Voci Ignorate",
"entries.ignored.scanning": "Scansione della Biblioteca in cerca di Voci Ignorate...",
"entries.ignored.title": "Correggi Voci Ignorate",
"entries.mirror": "&Replica",
"entries.mirror.confirmation": "Sei sicuro di voler replicare le seguenti {count} voci?",
"entries.mirror.label": "Replicazione {idx}/{total} Voci...",
"entries.mirror.title": "Replicazione Voci",
"entries.mirror.window_title": "Replica Voci",
"entries.remove.plural.confirm": "Sei sicuro di voler rimuovere queste <b>{count}</b> voci dalla tua biblioteca? Nessun file su disco verrà eliminato.",
"entries.remove.singular.confirm": "Sei sicuro di voler rimuovere questa voce dalla tua biblioteca? Nessun file su disco verrà eliminato.",
"entries.running.dialog.new_entries": "Aggiundendo {total} Nuove Voci di File...",
"entries.running.dialog.title": "Aggiungendo Nuove Voci di File",
"entries.tags": "Etichette",
"entries.unlinked.description": "Ogni voce della biblioteca è collegata ad un file in una delle tue cartelle. Se un file collegato ad una voce viene spostato o eliminito al di fuori di TagStudio, la voce corrispondente viene considerata scollegata.<br><br>Le voci scollegate possono essere ricollegate automaticamente attraverso la ricerca nelle tue cartelle oppure cancellate se lo si desidera.",
"entries.unlinked.relink.attempting": "Tentativo di Ricollegare {index}/{unlinked_count} Voci, {fixed_count} Ricollegate con Successo",
"entries.unlinked.relink.manual": "Ricollegamento &Manuale",
"entries.unlinked.relink.title": "Ricollegamento Voci",
"entries.unlinked.remove": "Rimuovi Voci non Collegate",
"entries.unlinked.remove_alt": "Rimuo&vi Voci non Collegate",
"entries.unlinked.scanning": "Scansionando la Biblioteca in cerca di Voci non Collegate...",
"entries.unlinked.search_and_relink": "&Ricerca && Ricollega",
"entries.unlinked.title": "Correggi Voci non Collegate",
"entries.unlinked.unlinked_count": "Voci non Collegate: {count}",
"ffmpeg.missing.description": "FFmpeg e/o FFprobe non sono stati trovati. FFmpeg è necessario per la riproduzione multimediale e per le miniature.",
"ffmpeg.missing.status": "{ffmpeg}: {ffmpeg_status}<br>{ffprobe}: {ffprobe_status}",
"field.copy": "Copia Campo",
"field.edit": "Modifica Campo",
"field.paste": "Incolla Campo",
"file.date_added": "Data Aggiunta",
"file.date_created": "Data di Creazione",
"file.date_modified": "Data di Modifica",
"file.dimensions": "Dimensioni",
"file.duplicates.description": "TagStudio supporta l'importazione di risultati di DupeGuru per gestire file duplicati.",
"file.duplicates.dupeguru.advice": "Dopo la replicazione, sei libero di usare DupeGuru per eliminare i file indesiderati. Dopodiché, usa la funzione \"Correggi Voci non Collegate\" di TagStudio nel menu Strumenti per eliminare le voci non collegate.",
"file.duplicates.dupeguru.file_extension": "File di DupeGuru (*.dupeguru)",
"file.duplicates.dupeguru.load_file": "&Carica File di DupeGuru",
"file.duplicates.dupeguru.no_file": "Nessun File DupeGuru Selezionato",
"file.duplicates.dupeguru.open_file": "Apri il File dei Risulati di DupeGuru",
"file.duplicates.fix": "Corregi File Duplicati",
"file.duplicates.matches": "File Duplicati Corrispondenti: {count}",
"file.duplicates.matches_uninitialized": "File Duplicati Corrispondenti: N/A",
"file.duplicates.mirror_entries": "&Replica Voci",
"file.duration": "Lunghezza",
"file.not_found": "File Non Trovato",
"file.open_file": "Apri file",
"file.open_file_with": "Apri file con",
"file.open_location.generic": "Mostra file in File Explorer",
"file.open_location.mac": "Mostra nel Finder",
"file.open_location.windows": "Mostra in File Explorer",
"file.path": "Percorso del File",
"folders_to_tags.close_all": "Chiudi Tutto",
"folders_to_tags.converting": "Conversione delle cartelle in Etichette",
"folders_to_tags.description": "Crea Etichette basate sulla struttura delle tue cartelle e le applica alle tue voci.\nLa struttura riportata di seguito mostra tutte le etichette che verranno create ed a che voci verranno applicate.",
"folders_to_tags.open_all": "Apri Tutto",
"folders_to_tags.title": "Crea Etichette dalle Cartelle",
"generic.add": "Aggiungi",
"generic.apply": "Applica",
"generic.apply_alt": "&Applica",
"generic.cancel": "Annulla",
"generic.cancel_alt": "&Annulla",
"generic.close": "Chiudi",
"generic.continue": "Continua",
"generic.copy": "Copia",
"generic.cut": "Taglia",
"generic.delete": "Elimina",
"generic.recent_libraries": "Librerias Recenti",
"generic.delete_alt": "&Elimina",
"generic.done": "Fatto",
"generic.done_alt": "&Fatto",
"generic.edit": "Modifica",
"generic.edit_alt": "&Modifica",
"generic.filename": "Nome File",
"generic.missing": "Mancante",
"generic.navigation.back": "Indietro",
"generic.navigation.next": "Prossimo",
"generic.no": "No",
"generic.none": "Nessuno",
"generic.overwrite": "Sovrascrivi",
"generic.overwrite_alt": "&Sovrascrivi",
"generic.paste": "Incolla",
"generic.recent_libraries": "Biblioteche Recenti",
"generic.remove": "Rimuovi",
"generic.remove_alt": "&RImuovi",
"generic.rename": "Rinomina",
"generic.rename_alt": "&Rinomina",
"generic.reset": "Ripristina",
"generic.save": "Salva",
"generic.skip": "Salta",
"generic.skip_alt": "&Salta",
"generic.yes": "Sì",
"home.search": "Cerca",
"menu.file": "File",
"home.search_entries": "Cerca Voci",
"home.search_library": "Cerca Biblioteca",
"home.search_tags": "Cerca Etichette",
"home.thumbnail_size": "Dimensione Miniature",
"home.thumbnail_size.extra_large": "Miniature Molto Grandi",
"home.thumbnail_size.large": "Miniature Grandi",
"home.thumbnail_size.medium": "Miniature Medie",
"home.thumbnail_size.mini": "Miniature Mini",
"home.thumbnail_size.small": "Miniature Piccole",
"ignore.open_file": "Mostra File \"{ts_ignore}\" su Disco",
"json_migration.checking_for_parity": "Controllo della Parità...",
"json_migration.creating_database_tables": "Creazione Tabelle di Database SQL...",
"json_migration.description": "<br>Avvia e visualizza in anteprima i risultati del processo di migrazione della biblioteca. La biblioteca convertita <i>non</i> verrà utilizzata finché non clicchi su \"Completa Migrazione\". <br><br>I dati della biblioteca devono avere valori corrispondenti o presentare un'etichetta \"Corrispondente\". I valori che non corrispondono saranno visualizzati in rosso e contrassegnati con un simbolo \"<b>(!)</b>\" accanto a loro.<br><center><i>Questo processo può richiedere diversi minuti per biblioteche di grandi dimensioni.</i></center>",
"json_migration.discrepancies_found": "Discrepanze Riscontrate nella Biblioteca",
"json_migration.discrepancies_found.description": "Sono state riscontrate delle discrepanze tra i formati originali e quelli della biblioteca convertita. Si prega di verificare e scegliere se continuare con la migrazione oppure se annullarla.",
"json_migration.finish_migration": "Completa Migrazione",
"json_migration.heading.aliases": "Alias:",
"json_migration.heading.colors": "Colori:",
"json_migration.heading.differ": "Discrepanze",
"json_migration.heading.extension_list_type": "Tipo di Lista di Entensioni:",
"json_migration.heading.file_extension_list": "Elenco Estensioni dei File:",
"json_migration.heading.match": "Abbinato",
"json_migration.heading.names": "Nomi:",
"json_migration.heading.parent_tags": "Etichette Padre:",
"json_migration.heading.paths": "Percorsi:",
"json_migration.heading.shorthands": "Abbreviazioni:",
"json_migration.migrating_files_entries": "Migrando {entries:,d} Voci di File...",
"json_migration.migration_complete": "Migrazione Completata!",
"json_migration.migration_complete_with_discrepancies": "Migrazione Completata, Discrepanze Rilevate",
"json_migration.start_and_preview": "Avvio ed Anteprima",
"json_migration.title": "Salva Formato Migrazione: \"{path}\"",
"json_migration.title.new_lib": "<h2>v9.5+ Biblioteca</h2>",
"json_migration.title.old_lib": "<h2>v9.4 Biblioteca</h2>",
"landing.open_create_library": "Apri/Crea Biblioteca {shortcut}",
"library.field.add": "Aggiungi Campo",
"library.field.confirm_remove": "Sei sicuro di voler rimuovere il campo \"{name}\"?",
"library.field.mixed_data": "Dati Misti",
"library.field.remove": "Rimuovi Campo",
"library.missing": "Manca la Posizione della Biblioteca",
"library.name": "Biblioteca",
"library.refresh.scanning.plural": "Ricerca di Nuovi File nelle Cartelle...\n{searched_count} Files Cercati, {found_count} Nuovi File Trovati",
"library.refresh.scanning.singular": "Ricerca di Nuovi File nelle Cartelle...\n{searched_count} File Cercati, {found_count} Nuovi File Trovati",
"library.refresh.scanning_preparing": "Ricerca di Nuovi File nelle Cartelle...\nPreparazione in corso...",
"library.refresh.title": "Aggiornamento delle Cartelle",
"library.scan_library.title": "Scansione della Biblioteca",
"library_info.cleanup": "Pulizia",
"library_info.cleanup.backups": "Backup della Biblioteca:",
"library_info.cleanup.dupe_files": "File Duplicati:",
"library_info.cleanup.ignored": "Voci Ignorate:",
"library_info.cleanup.unlinked": "Voci non Collegate:",
"library_info.stats": "Statistiche",
"library_info.stats.colors": "Colori Etichette:",
"library_info.stats.entries": "Voci:",
"library_info.stats.fields": "Campi:",
"library_info.stats.macros": "Macro:",
"library_info.stats.namespaces": "Spazi dei Nomi:",
"library_info.stats.tags": "Etichette:",
"library_info.title": "Biblioteca '{library_dir}'",
"library_info.version": "Versione del Formato della Biblioteca: {version}",
"library_object.name": "Nome",
"library_object.name_required": "Nome (Obbligatorio)",
"library_object.slug": "ID Slug",
"library_object.slug_required": "ID Slug (Obbligatorio)",
"macros.running.dialog.new_entries": "Esecuzione delle Macro Configurate su {count}/{total} Nuove Voci di File...",
"macros.running.dialog.title": "Esecuzione delle Macro sulle Nuove Voci",
"media_player.autoplay": "Riproduzione Automatica",
"media_player.loop": "Metti in Loop",
"menu.delete_selected_files_ambiguous": "Sposta File nel {trash_term}",
"menu.delete_selected_files_plural": "Sposta Files nel {trash_term}",
"menu.delete_selected_files_singular": "Sposta il File nel {trash_term}",
"menu.edit": "Modifica",
"menu.edit.ignore_files": "Ignora File e Cartelle",
"menu.edit.manage_tags": "Gestisci Etichette",
"menu.edit.new_tag": "Nuova &Etichetta",
"menu.file": "&File",
"menu.file.clear_recent_libraries": "Cancella Recenti",
"menu.file.close_library": "&Chiudi Biblioteca",
"menu.file.missing_library.message": "La posizione della biblioteca \"{library}\" non può essere trovata.",
"menu.file.missing_library.title": "Biblioteca Mancante",
"menu.file.new_library": "Nuova Biblioteca",
"menu.file.open_backups_folder": "Apri Cartella dei Backup",
"menu.file.open_create_library": "&Apri/Crea Biblioteca",
"menu.file.open_library": "Apri Biblioteca",
"menu.file.open_recent_library": "Apri Recenti",
"menu.file.refresh_directories": "&Aggiorna Cartelle",
"menu.file.save_backup": "&Salva Backup della Biblioteca",
"menu.file.save_library": "Salva Biblioteca",
"menu.help": "&Aiuto",
"menu.help.about": "Informazioni",
"menu.macros": "&Macro",
"menu.macros.folders_to_tags": "Cartelle ad Etichette",
"menu.select": "Seleziona",
"menu.settings": "Impostazioni...",
"menu.tools": "&Strumenti",
"menu.tools.fix_duplicate_files": "Coreggi File &Duplicati",
"menu.tools.fix_ignored_entries": "Correggi Voci &Ignorate",
"menu.tools.fix_unlinked_entries": "Correggi Voci &Scollegate",
"menu.view": "&Visualizza",
"menu.view.decrease_thumbnail_size": "Riduci Dimensione Miniature",
"menu.view.increase_thumbnail_size": "Aumenta Dimensione Miniature",
"menu.view.library_info": "&Informazioni Biblioteca",
"menu.window": "Finestra",
"tag.add": "Aggiungi Tag",
"namespace.create.description": "Gli spazi dei nomi sono usati da TagStudio per separare gruppi di elementi come etichette e colori in maniera da facilitarne l'esportazione e la condivisione. Gli spazi dei nomi che iniziano con \"tagstudio\" sono riservati per l'uso interno di TagStudio.",
"namespace.create.description_color": "I colori delle etichette usano gli spazi dei nomi come gruppi di tavolozze di colori. Tutti i colori personalizzati devono prima essere inseriti in uno spazio dei nomi.",
"namespace.create.title": "Crea Spazio dei Nomi",
"namespace.new.button": "Nuovo Spazio dei Nomi",
"namespace.new.prompt": "Crea un Nuovo Spazio dei Nomi per Iniziare ad Aggiungere Colori Personalizzati!",
"preview.ignored": "Ignorato",
"preview.multiple_selection": "<b>{count}</b> Elementi Selezionati",
"preview.no_selection": "Nessun Elemento Selezionato",
"preview.unlinked": "Scollegato",
"select.add_tag_to_selected": "Aggiungi Etichetta alla Selezione",
"select.all": "Seleziona Tutto",
"select.clear": "Cancella Selezione",
"select.inverse": "Inverti Selezione",
"settings.clear_thumb_cache.title": "Cancella Cache delle Miniature",
"settings.dateformat.english": "Inglese",
"settings.dateformat.international": "Internazionale",
"settings.dateformat.label": "Formato Data",
"settings.dateformat.system": "Sistema",
"settings.filepath.label": "Visibilità del Percorso del File",
"settings.filepath.option.full": "Mostra Percorsi Completi",
"settings.filepath.option.name": "Mostra Solo i Nomi dei File",
"settings.filepath.option.relative": "Mostra Percorsi Relativi",
"settings.generate_thumbs": "Generazione delle Miniature",
"settings.global": "Impostazioni Globali",
"settings.hourformat.label": "Formato a 24 Ore",
"settings.infinite_scroll": "Scorrimento Infinito",
"settings.language": "Lingua",
"settings.library": "Impostazioni Biblioteca",
"settings.open_library_on_start": "Apri Biblioteca all'Avvio",
"settings.page_size": "Dimensione Pagina",
"settings.restart_required": "Riavvia TagStudio affinchè le modifiche abbiano effetto.",
"settings.show_filenames_in_grid": "Mostra Nomi dei File nella Griglia",
"settings.show_recent_libraries": "Mostra Biblioteche Recenti",
"settings.splash.label": "Schermata Iniziale",
"settings.splash.option.classic": "Classico (9.0)",
"settings.splash.option.default": "Predefinito",
"settings.splash.option.goo_gears": "Open Source (9.4)",
"settings.splash.option.ninety_five": "'95 (9.5)",
"settings.splash.option.random": "Casuale",
"settings.tag_click_action.add_to_search": "Aggiungi Etichette alla Ricerca",
"settings.tag_click_action.label": "Azione di Clic sulle Etichette",
"settings.tag_click_action.open_edit": "Modifica Etichetta",
"settings.tag_click_action.set_search": "Cerca Etichetta",
"settings.theme.dark": "Scuro",
"settings.theme.label": "Tema:",
"settings.theme.light": "Chiaro",
"settings.theme.system": "Sistema",
"settings.thumb_cache_size.label": "Dimensione Cache delle Miniature",
"settings.title": "Impostazioni",
"sorting.direction.ascending": "Ascendente",
"sorting.direction.descending": "Discendente",
"sorting.mode.random": "Casuale",
"splash.opening_library": "Aprendo Biblioteca \"{library_path}\"...",
"status.deleted_file_plural": "{count} file eliminati!",
"status.deleted_file_singular": "1 file eliminato!",
"status.deleted_none": "Nessun file eliminato.",
"status.deleted_partial_warning": "Solo {count} file sono stati eliminati! Verifica se alcuni dei file sono attualmente mancanti o in uso.",
"status.deleting_file": "Eliminano file [{i}/{count}]: \"{path}\"...",
"status.library_backup_in_progress": "Salvataggio Backup della Biblioteca...",
"status.library_backup_success": "Backup della BIblioteca Salvato in: \"{path}\" ({time_span})",
"status.library_closed": "Biblioteca Chiusa ({time_span})",
"status.library_closing": "Chiudendo la Biblioteca...",
"status.library_save_success": "Biblioteca Salvata e Chiusa!",
"status.library_search_query": "Cercando nella Biblioteca...",
"status.library_version_expected": "Previsto:",
"status.library_version_found": "Trovato:",
"status.library_version_mismatch": "Versione della Biblioteca non Corrispondente!",
"status.results": "Risultati",
"status.results.invalid_syntax": "Sintassi di Ricerca Non Valida:",
"status.results_found": "{count} Risultati Trovati ({time_span})",
"tag.add": "Aggiungi Etichetta",
"tag.add.plural": "Aggiungi Etichette",
"tag.add_to_search": "Aggiungi alla Ricerca",
"tag.aliases": "Alias",
"tag.all_tags": "Tutte le Etichette",
"tag.choose_color": "Scegli Colore dell'Etichetta",
"tag.color": "Colore",
"tag.confirm_delete": "Sei sicuro di voler eliminare l'etichetta \"{tag_name}\"?",
"tag.create": "Crea Etichetta",
"tag.create_add": "Crea && Aggiungi \"{query}\"",
"tag.disambiguation.tooltip": "Usa questa etichetta per la disambiguazione",
"tag.edit": "Modifica Etichetta",
"tag.is_category": "È Categoria",
"tag.name": "Nome",
"tag.new": "Nuovo Tag"
"tag.new": "Nuova Etichetta",
"tag.parent_tags.add": "Aggiungi Etichette Padre",
"tag.parent_tags.description": "Questa etichetta può essere considerata come sostitutiva di qualunque di queste Etichette Padre nelle richerche.",
"tag.remove": "Rimuovi Etichetta",
"tag.search_for_tag": "Cerca Etichetta",
"tag.shorthand": "Abbreviazione",
"tag.tag_name_required": "Nome Etichetta (Obbligatorio)",
"tag.view_limit": "Limite di Visualizzazione:",
"tag_manager.title": "Etichette della Biblioteca",
"trash.context.ambiguous": "Sposta file(s) in {trash_term}",
"trash.context.plural": "Sposta files in {trash_term}",
"trash.context.singular": "Sposta file in {trash_term}",
"trash.dialog.disambiguation_warning.plural": "Questo li rimuoverà da TagStudio <i>E</i> dal tuo sistema di file!",
"trash.dialog.disambiguation_warning.singular": "Questo lo rimuoverà da TagStudio <i>E</i> dal tuo sistema di file!",
"trash.dialog.move.confirmation.plural": "Sei sicuro di voler spostare questi {count} file nel {trash_term}?",
"trash.dialog.move.confirmation.singular": "Sei sicuro di voler spostare questo file nel {trash_term}?",
"trash.dialog.permanent_delete_warning": "<b>ATTENZIONE!</b> Se questo file non può essere spostato nel {trash_term}, verrà <b>eliminato permanentemente!</b>",
"trash.dialog.title.plural": "Elimina Files",
"trash.dialog.title.singular": "Elimina File",
"trash.name.generic": "Spazzatura",
"trash.name.windows": "Cestino",
"view.size.0": "Mini",
"view.size.1": "Piccolo",
"view.size.2": "Medio",
"view.size.3": "Grande",
"view.size.4": "Molto Grande",
"window.message.error_opening_library": "Errore nell'apertura della biblioteca.",
"window.title.error": "Errore",
"window.title.open_create_library": "Apri/Crea Biblioteca"
}

View File

@@ -145,7 +145,6 @@ def test_title_update(
qt_driver.main_window.menu_bar.fix_dupe_files_action = QAction(menu_bar)
qt_driver.main_window.menu_bar.clear_thumb_cache_action = QAction(menu_bar)
qt_driver.main_window.menu_bar.folders_to_tags_action = QAction(menu_bar)
qt_driver.main_window.menu_bar.macros_menu = None
# Trigger the update
qt_driver._init_library(library_dir, open_status) # pyright: ignore[reportPrivateUsage]

View File

@@ -1,12 +1,13 @@
# Copyright (C) 2025
# Licensed under the GPL-3.0 License.
# Created for TagStudio: https://github.com/CyanVoxel/TagStudio
from PySide6.QtCore import SIGNAL
from pytestqt.qtbot import QtBot
from tagstudio.core.library.alchemy.library import Library
from tagstudio.qt.mixed.tag_search import TagSearchPanel
from tagstudio.qt.mixed.tag_widget import TagWidget
from tagstudio.qt.ts_qt import QtDriver
def test_update_tags(qtbot: QtBot, library: Library):
@@ -17,3 +18,35 @@ def test_update_tags(qtbot: QtBot, library: Library):
# When
panel.update_tags()
def test_tag_widget_actions_replaced_correctly(qtbot: QtBot, qt_driver: QtDriver, library: Library):
panel = TagSearchPanel(library)
qtbot.addWidget(panel)
panel.driver = qt_driver
# Set the widget
tags = library.tags
panel.set_tag_widget(tags[0], 0)
tag_widget: TagWidget = panel.scroll_layout.itemAt(0).widget()
should_replace_actions = {
tag_widget: ["on_edit()", "on_remove()"],
tag_widget.bg_button: ["clicked()"],
tag_widget.search_for_tag_action: ["triggered()"],
}
# Ensure each action has been set
ensure_one_receiver_per_action(should_replace_actions)
# Set the widget again
panel.set_tag_widget(tags[0], 0)
# Ensure each action has been replaced (amount of receivers is still 1)
ensure_one_receiver_per_action(should_replace_actions)
def ensure_one_receiver_per_action(should_replace_actions):
for action, signal_strings in should_replace_actions.items():
for signal_str in signal_strings:
assert action.receivers(SIGNAL(signal_str)) == 1