Compare commits
66 Commits
v12.4.10.2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74c76a7414 | ||
|
|
17a0c21453 | ||
|
|
fc9c9dfe48 | ||
|
|
d5f0e39981 | ||
|
|
0f6493f4af | ||
|
|
454b490a06 | ||
|
|
ffea2648aa | ||
|
|
1ac967500c | ||
|
|
ed5afe5d0f | ||
|
|
ab075d0bef | ||
|
|
7fb1adb41b | ||
|
|
9735a8391c | ||
|
|
dbdfdbc536 | ||
|
|
3b86fc405f | ||
|
|
4ea7f04921 | ||
|
|
5b59b442ab | ||
|
|
b5d9c0a27a | ||
|
|
f5cbf89e13 | ||
|
|
00dc9e020d | ||
|
|
bfa0e4d338 | ||
|
|
5ceda408da | ||
|
|
716b1923a4 | ||
|
|
1148d8125d | ||
|
|
690fd10e42 | ||
|
|
736fbbf82f | ||
|
|
eda100b7ac | ||
|
|
ceb007500d | ||
|
|
05fad01624 | ||
|
|
e1d789ccdc | ||
|
|
d0f00f3f1e | ||
|
|
6ab82dba7b | ||
|
|
0045202334 | ||
|
|
4c80813651 | ||
|
|
6b637b35ab | ||
|
|
9b55ffa715 | ||
|
|
65da7890f1 | ||
|
|
72f92ec6c0 | ||
|
|
4efc084375 | ||
|
|
f955daa5ed | ||
|
|
144ab2162a | ||
|
|
6d0c4a9b3c | ||
|
|
8a682533c1 | ||
|
|
cecabc911e | ||
|
|
e35f5209dc | ||
|
|
4ffe70af0e | ||
|
|
233ba3184f | ||
|
|
ac4c168725 | ||
|
|
db588629c0 | ||
|
|
29be091a4b | ||
|
|
82a48db57b | ||
|
|
9f0f32a462 | ||
|
|
f64239b5ee | ||
|
|
bc8a35aedd | ||
|
|
2fca6b8b91 | ||
|
|
bc2eddd2dd | ||
|
|
ae012548bd | ||
|
|
76a59873ea | ||
|
|
3129fdba7b | ||
|
|
1771813849 | ||
|
|
7024bbf823 | ||
|
|
663f70b8bf | ||
|
|
7741e3caff | ||
|
|
c82eefa768 | ||
|
|
0e4231906a | ||
|
|
9bca84dca4 | ||
|
|
ca30fd41c6 |
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
27
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -6,10 +6,14 @@ labels: bug
|
||||
assignees: ''
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
PLEASE FILL OUT THE FOLLOWING. Bug reports with limited information or lacking an attached log file may get limited or delayed help.
|
||||
|
||||
___
|
||||
|
||||
## Describe the bug
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
## To Reproduce
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
1. Go to '...'
|
||||
@ -17,14 +21,23 @@ Steps to reproduce the behavior:
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
## Expected behavior
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
## Screenshots
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Platform**
|
||||
## Platform
|
||||
[e.g. Windows 10, Windows 11, Mac, Linux (State distribution)]
|
||||
|
||||
**Log Files**
|
||||
Attach your Libation log file here. Logs are typically in your `[user]\Libation` folder. (For example, on windows: `C:\my_username\Libation`) Also within Libation, on the first tab in Settings you can click the button 'Open log folder'. If your user folder contains the file "LibationCrash.log", attach that also.
|
||||
## Log Files
|
||||
Attach your Libation log file here. If your user folder contains the file "LibationCrash.log", attach that also.
|
||||
|
||||
**Default Log File Locations**
|
||||
|Platform|Folder|
|
||||
|-|-|
|
||||
|Windows|`%userprofile%\Libation`|
|
||||
|macOS|`~/Library/Application Support/Libation`|
|
||||
|Linux|`~/.local/share/Libation`|
|
||||
|
||||
Alternative, you may open the log file folder from within Libation. Open Libation's settings, and on the first tab in Settings you can click the button 'Open log folder'.
|
||||
|
||||
4
.github/workflows/build-linux.yml
vendored
4
.github/workflows/build-linux.yml
vendored
@ -41,9 +41,9 @@ jobs:
|
||||
name: "${{ inputs.OS }}-${{ inputs.architecture }}"
|
||||
runs-on: ${{ inputs.runs_on }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v5
|
||||
with:
|
||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||
env:
|
||||
|
||||
4
.github/workflows/build-windows.yml
vendored
4
.github/workflows/build-windows.yml
vendored
@ -42,9 +42,9 @@ jobs:
|
||||
release_name: classic
|
||||
prefix: Classic-
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Setup .NET
|
||||
uses: actions/setup-dotnet@v4
|
||||
uses: actions/setup-dotnet@v5
|
||||
with:
|
||||
dotnet-version: ${{ env.DOTNET_VERSION }}
|
||||
env:
|
||||
|
||||
2
.github/workflows/docker.yml
vendored
2
.github/workflows/docker.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -40,7 +40,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
uses: actions/download-artifact@v5
|
||||
with:
|
||||
path: artifacts
|
||||
pattern: "*(Classic-)Libation.*"
|
||||
|
||||
@ -17,6 +17,6 @@ jobs:
|
||||
container:
|
||||
image: ghcr.io/flathub/flatpak-builder-lint:latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- name: Check the MetaInfo file
|
||||
run: flatpak-builder-lint appstream Source/LoadByOS/LinuxConfigApp/com.getlibation.Libation.metainfo.xml
|
||||
|
||||
2
.github/workflows/validate-desktop-file.yaml
vendored
2
.github/workflows/validate-desktop-file.yaml
vendored
@ -15,7 +15,7 @@ jobs:
|
||||
validate-desktop-file:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- run: sudo apt --yes install desktop-file-utils
|
||||
- name: Check the desktop file
|
||||
run: desktop-file-validate Source/LoadByOS/LinuxConfigApp/Libation.desktop
|
||||
|
||||
13
.vscode/launch.json
vendored
13
.vscode/launch.json
vendored
@ -6,7 +6,7 @@
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": ".NET Core Launch (console)",
|
||||
"name": ".NET Core Launch (console) Windows",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
@ -15,6 +15,17 @@
|
||||
"cwd": "${workspaceFolder}",
|
||||
"stopAtEntry": false,
|
||||
"console": "internalConsole"
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Launch (console) Linux",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build_linux",
|
||||
"program": "${workspaceFolder}/Source/bin/Avalonia/Debug/Libation.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"stopAtEntry": false,
|
||||
"console": "internalConsole"
|
||||
}
|
||||
|
||||
]
|
||||
|
||||
17
.vscode/tasks.json
vendored
17
.vscode/tasks.json
vendored
@ -37,6 +37,23 @@
|
||||
//"reveal": "silent"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
},
|
||||
{
|
||||
"label": "build_linux",
|
||||
"type": "shell",
|
||||
"command": "dotnet",
|
||||
"args": [
|
||||
"build",
|
||||
"${workspaceFolder}/Source/LibationAvalonia/LibationAvalonia.csproj",
|
||||
"-p:TargetFramework=net9.0",
|
||||
"-p:TargetFrameworks=net9.0",
|
||||
"-p:RuntimeIdentifier=linux-x64"
|
||||
],
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
//"reveal": "silent"
|
||||
},
|
||||
"problemMatcher": "$msCompile"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -12,6 +12,7 @@
|
||||
- [Custom File Naming](NamingTemplates.md)
|
||||
- [Command Line Interface](#command-line-interface)
|
||||
- [Custom Theme Colors](#custom-theme-colors) (Chardonnay Only)
|
||||
- [Audio Formats (Dolby Atmos, Widevine, Spacial Audio)](AudioFileFormats.md)
|
||||
|
||||
|
||||
|
||||
|
||||
104
Documentation/AudioFileFormats.md
Normal file
104
Documentation/AudioFileFormats.md
Normal file
@ -0,0 +1,104 @@
|
||||
# Audio Formats Produced by Libation
|
||||
|
||||
Libation will download audio in a number of different audio formats, depending on the settings you choose within Libation and the per-title availability of audio formats from Audible. The Libation settings which affect the format downloaded by Libation are shown in the Settings menu screenshot below.
|
||||
|
||||
Notes:
|
||||
- Audiobook file extensions are either `.m4b` or `.mp3`. Libation uses the `.m4b` file extension for all non-MP3 files, regardless of the audio codec contained therein. Some media players don't recognize the `.m4b` file extension and may require the extension be changed to `.m4a` or `.mp4`.
|
||||
- Most (but not all) podcasts are delivered by Audible as native MP3 files. None of the following audio formats and settings discussions pertain to those podcasts because MP3s have no DRM, and those episodes are copied directly to their output folders.
|
||||
|
||||

|
||||
|
||||
## Settings Summary
|
||||
### Audio quality to request from Audible
|
||||
Audiobooks can be requested from Audible as "Normal" quality or "High" quality, matching the settings in the Audible mobile apps. This setting affects the audio bitrate and, sometimes, the number of audio channels. This setting has no effect on the _audio codec_.
|
||||
|
||||
### Use Widevine DRM
|
||||
When this setting is disabled, all audiobooks will be downloaded using Audible's in-house DRM (AAX(C)) in the [AAC-LC](#aac-lc) format.
|
||||
When this setting is enabled, Libation will request audio files protected by Google's Widevine Digital Rights Managements scheme, and two additional settings will be unlocked: [Request xHE-AAC Codec](#request-xhe-aac-codec) and [Request Spatial Audio](#request-spatial-audio) (explained further below).
|
||||
|
||||
If you don't enable either of those additional options, then enabling 'Use Widevine DRM' will have no pratcical effect in nearly all circumstances. Audiobooks will be downloaded in the same [AAC-LC](#aac-lc) format with the same bitrate and the same number of audio channels. On rare occasions, enabling 'Use Widevine DRM' without the other two options will result in audio files with a different bitrate.
|
||||
|
||||
### Request xHE-AAC Codec
|
||||
Enable this setting to request audiobooks in the [xHE-AAC](#xhe-aac) format. This codec is generally better quality than the [AAC-LC](#aac-lc) codec at the same bitrate, but it isn't as commonly supported by media players, so you may have some difficulty playing these audiobooks. The highest bitrate version of some audiobooks is only available as [xHE-AAC](#xhe-aac).
|
||||
|
||||
### Request Spatial Audio
|
||||
Enable this setting to request audiobooks in a "spatial" ([Dolby Atmos](#dolby-atmos)) audio format. If an audiobook is not available in a spatial format, it will instead be downloaded in the [xHE-AAC codec](#xhe-aac).
|
||||
|
||||
### Spatial audio codec
|
||||
Choose whether spatial audiobooks are downloaded in the [E-AC-3](#e-ac-3) or [AC-4](#ac-4) format.
|
||||
|
||||
### Download my books in the original audio format (Lossless)
|
||||
If selected, Audiobooks will be downloaded and saved in the format delivered by audible (which depends on the settings explained above). Libation will not change the audio.
|
||||
|
||||
### Download my books as .MP3 files (transcode if necessary).
|
||||
If selected, Libation will decode [AAC-LC](#aac-lc), [xHE-AAC](#xhe-aac), and [E-AC-3](#e-ac-3) audiobooks and re-encode them as MP3s using the MP3 encoder settings ([read about LAME MP3 encoder settings](https://lame.sourceforge.io/lame_ui_example.php)). Note that Libation cannot convert [AC-4](#ac-4) audio to MP3.
|
||||
|
||||
# Audio Formats
|
||||
|
||||
## Traditional Mono and Stereo Formats
|
||||
|
||||
### AAC-LC
|
||||
#### _Full Name_
|
||||
Advanced Audio Coding - Low Complexity
|
||||
#### _Description_
|
||||
This is the base profile for AAC audio and has existed since AAC's initial release in 1997. It enjoys wide support on nearly every conceivable platform capable of playing digital audio, as ubiquitous as MP3.
|
||||
If Widevine support is not enabled, or if the book is not available in the more high-definition formats, Libation will download audiobooks in this format.
|
||||
|
||||
### MP3
|
||||
#### _Full Name_
|
||||
MPEG-1 Audio Layer III or MPEG-2 Audio Layer III
|
||||
#### _Description_
|
||||
An older (released in 1991) but still nearly universally supported audio codec. Its audio quality is generally worse than AAC-LC at similar bitrates. Audible delivers some podcasts in MP3 format, but no audiobooks are natively availble as MP3. Libation supports converting Audiobooks delivered in other audio formats to MP3. Note that the MP3 format supports a maximum of two audio channels, so multichannel E-AC-3 audio will be downsampled to stereo or mono (depending on the Libation's settings). [AC-4](#ac-4) cannot be converted to MP3.
|
||||
|
||||
### xHE-AAC
|
||||
#### _Full Name_
|
||||
Extended High-Efficiency Advanced Audio Coding
|
||||
#### _Description_
|
||||
This is a proprietary codec created by the [Fraunhofer Institute for Integrated Circuits IIS](https://www.iis.fraunhofer.de/en/ff/amm/broadcast-streaming/xheaac.html). It combines features of the HE-AAC v2 and the baseline USAC (Unified Speech and Audio Coding) profiles with the parts of the MPEG-D DRC Loudness Control Profile or Dynamic Range Control Profile. Therefore, USAC and xHE-AAC are not synonymous and should not be used interchangeably. A player capable of decoding USAC will not necessarily be able to decode xHE-AAC.
|
||||
|
||||
xHE-AAC boasts significantly higher quality audio at low bitrates. Though it has existed since at least 2016, playback support is still quite limited. FFmpeg has recently added partial decoder support for the USAC profiles, but it is insufficient to decode the xHE-AAC audio files acquired from Audible (due to FFmpeg's lack of support for MPEG Surround for Mono to Stereo Upmixing; ISO 23003-3:2012 §7.11)
|
||||
|
||||
Note that the xHE-AAC files authored by Audible have some USAC conformance errors including:
|
||||
- Number of samples per frame not matching the UsacConfig coreCoderFrameLength value.
|
||||
- Disagreement between stts and UsacFrame usacIndependencyFlag value.
|
||||
- Stts indicating a frame is an immediate play-out frame, but USAC AudioPreRoll is absent.
|
||||
|
||||
## Dolby Atmos
|
||||
Atmos is a surround sound technology that expands on existing surround sound systems by adding height channels as well as free-moving sound objects. Audible delivers Dolby Atmos in two formats: E-AC-3 and AC-4.
|
||||
|
||||
Your device's ability to play audio from these formats does not necessarily mean that the audio you are hearing is Atmos (spatial). For instance, downloading the AC-4 codec for Windows ([links in the [Supported media Players](#supported-media-players) section) will enable you to play AC-4 audiobooks, but you'll still need to download [Dolby Access](https://apps.microsoft.com/detail/9n0866fs04w8?hl=en-US&gl=US) and pay $15 to enable _Dolby Atmos For Headphones_. Please refer to [this comment](https://github.com/rmcrackan/Libation/pull/1331#discussion_r2268660524) for additional context.
|
||||
|
||||
### E-AC-3
|
||||
#### _Full Name_
|
||||
Dolby Digital Plus (a.k.a Enhanced AC-3, DDP, DD+, and EC-3)
|
||||
#### _Description_
|
||||
A proprietary digital audio compression scheme developed by Dolby Digital for the transport and storage of multichannel audio. This format can be extended to add support for Atmos, making the codec _Dolby Digital Plus Atmos_. _Dolby Digital Plus Atmos_ is backwards compatible with Dolby Digital Plus, so any media player capable of playing Dolby Digital Plus can play _Dolby Digital Plus Atmos_. Audible spatial audiobooks downloaded in the E-AC-3 format are _Dolby Digital Plus Atmos_. If they are played by a media player that supports Atmos, they will play as Atmos audio. If they are played by a media player that does not support Atmos, they will be played as traditional 5.1 surround audio.
|
||||
|
||||
### AC-4
|
||||
#### _Full Name_
|
||||
Dolby AC-4
|
||||
#### _Description_
|
||||
A proprietary audio compression technology developed by Dolby Digital for the transport and storage of audio channels and/or audio objects. Audible spatial audiobooks downloaded in the AC-4 format are 2-channel AC-4 Immersive Stereo (AC4-IMS) audio, intended for playback in headphones or earbuds (though apparently [not supported on Apple devices](https://github.com/rmcrackan/Libation/issues/996#issuecomment-3169574514)).
|
||||
|
||||
# Supported Media Players
|
||||
Below is an incomplete matrix of codec support across various media players and platforms.
|
||||
| Player | [AAC-LC](#aac-lc) | [xHE-AAC](#xhe-aac) | [E-AC-3](#e-ac-3) | [AC-4](#ac-4) |
|
||||
| :--- | :---: | :---: | :---: | :---: |
|
||||
|Windows Native Support|Yes|Yes<sup>1</sup>|Yes<sup>2,3</sup>|Yes<sup>4</sup>|
|
||||
|macOS Native Support|Yes|Yes|Yes<sup>3</sup>| |
|
||||
|Android Native Support<sup>5</sup>|Yes|Yes| | |
|
||||
|FFmpeg (all platforms)|Yes|Yes<sup>6</sup>|Yes<sup>3</sup>||
|
||||
|[VLC](https://www.videolan.org/vlc/) (Windows)|Yes| |Yes<sup>3</sup> | |
|
||||
|[foobar2000](https://www.foobar2000.org/components) (Windows and Mac)|Yes|Yes<sup>7</sup> | | |
|
||||
|[PotPlayer](https://potplayer.daum.net/) (Windows)|Yes|Yes|Yes<sup>3</sup>| |
|
||||
|[Samsung Media Player](https://play.google.com/store/apps/details?id=com.sec.android.app.music)<sup>8</sup> (Samsung devices) |Yes|Yes|Yes|Yes|
|
||||
|
||||
1. Windows 11 22H2 and later
|
||||
2. On Windows [prior to Windows 11, version 24H2](https://support.microsoft.com/en-us/windows/codecs-in-media-player-d5c2cdcd-83a2-4805-abb0-c6888138e456). You can still get the codec by running the following command from a Windows PowerShell console: `winget install --id 9nvjqjbdkn97`
|
||||
3. As mentioned in the [Dolby Atmos](#dolby-atmos) section, just because a media player can play a file does not mean it's rendering Atmos. _Dolby Digital Plus Atmos_ is backwards compatible with _Dolby Digital Plus_, so media players which only support _Dolby Digital Plus_ will play E-AC-3 audio files as regular 5.1 surround without rendering the Atmos spatial qualities. Additional software or hardware support may be required for Dolby Atmos playback.
|
||||
4. You can download the AC-4 codec for Windows from 3rd party sites like [Major Geeks](https://www.majorgeeks.com/files/details/dolby_ac_3ac_4_installer.html) and [Free-Codecs](https://www.free-codecs.com/dolby-ac-4-decoder_download.htm). Once you install the codec bundle from one of those sources, the Windows store app will keep it updated. Read more about the process [in this comment](https://github.com/rmcrackan/Libation/pull/1331#discussion_r2268660524).
|
||||
5. All Android devices will support AAC-LC and xHE-AAC. Some manufactures (such as Samsung) will include Dolby codecs for playing E-AC-3 and AC-4 audio.
|
||||
6. requires FFmpeg to be [built with fdk-aac](https://trac.ffmpeg.org/wiki/Encode/AAC#fdk_aac). You will almost certainly not find pre-build binaries in the wild due to licensing restrictions.
|
||||
7. Requires the [fdk-aac plugin](https://www.foobar2000.org/components/view/foo_pd_aac) (Windows only)
|
||||
8. Requires audio file extensions to be `.m4a` or `.mp4`. Libation sets the file extensions to `.m4b`, so you must manually change it to `.m4a` by renaming the audio file.
|
||||
|
||||
@ -35,9 +35,19 @@ Self-hosting online:
|
||||
* [audiobookshelf](https://www.audiobookshelf.org). On [reddit](https://www.reddit.com/r/audiobookshelf/)
|
||||
* [plex](https://www.plex.tv/). Listen with [Prologue](https://prologue.audio/) (iOS)
|
||||
|
||||
## Q: I'm having trouble playing my non-spatial audiobook, how can I fix this?
|
||||
|
||||
**A:** If you enabled the [Request xHE-AAC Codec](AudioFileFormats.md#request-xhe-aac-codec) option in settings, then the audiobook is being downloaded in the [xHE-AAC codec](AudioFileFormats.md#xhe-aac) which isn't widely supported. You have two options:
|
||||
1. Use a media player which supports the xHE-AAC codec. [See an incomplete list of media players which support xHE-AAC](AudioFileFormats.md#supported-media-players).
|
||||
2. Disable the [Request xHE-AAC Codec](AudioFileFormats.md#request-xhe-aac-codec) option in settings and re-download the audiobook. This will cause Libation to download audiobooks in the [AAC-LC codec](AudioFileFormats.md#aac-lc), which enjoys near-universal media player support.
|
||||
|
||||
## Q: I'm having trouble playing my book with 4D, spatial audio, or Dolby Atmos, how can I fix this?
|
||||
|
||||
**A:** Spatial audiobooks are delivered in two formats: [E-AC-3](AudioFileFormats.md#e-ac-3) and [AC-4](AudioFileFormats.md#ac-4). [See an incomplete list of media players which support those codecs](AudioFileFormats.md#supported-media-players).
|
||||
|
||||
## Q: I'm having trouble loggin into my Brazil account.
|
||||
|
||||
For reasons known only to Jeff Bezos and God, amazon and audible brazil handle logins slightly differently. The external browser login option is not possible for Brazil. [See this ticket for more details.](https://github.com/rmcrackan/Libation/issues/1103)
|
||||
**A:** For reasons known only to Jeff Bezos and God, amazon and audible brazil handle logins slightly differently. The external browser login option is not possible for Brazil. [See this ticket for more details.](https://github.com/rmcrackan/Libation/issues/1103)
|
||||
|
||||
## Q: How do I use Libation with a South Africa account?
|
||||
|
||||
|
||||
64
Documentation/LinuxDevelopmentSetupUsingNix.md
Normal file
64
Documentation/LinuxDevelopmentSetupUsingNix.md
Normal file
@ -0,0 +1,64 @@
|
||||
# Development Environment Setup using Nix or Nix Flakes on Linux x86_64
|
||||
[Nix flakes](https://nixos.wiki/wiki/Flakes) can be used to provide version controlled reproducible and cross-platform development environments. The key files are:
|
||||
- `flake.nix`: Defines the flake inputs and outputs, including development shells.
|
||||
- `shell.nix`: This file defines the dependencies and additionally adds support for the Impure `nix-shell` method. This is used by the flake to create the dev environment.
|
||||
- `flake.lock`: Locks the versions of inputs for reproducibility.
|
||||
---
|
||||
## Prerequisites
|
||||
- [Nix](https://nixos.org/download.html) the package manager or NixOs installed on Linux (x86_64-linux)
|
||||
- Optional: flakes support enabled.
|
||||
---
|
||||
## Using the Development Shell
|
||||
You have two primary ways to enter the development shell with Nix:
|
||||
### 1. Using `nix develop` (flake-native command)
|
||||
This is the recommended way if you have Nix with flakes support. Flake guarantee the versions of the dependencies and can be controlled through `flake.nix` and `flake.lock`.
|
||||
```
|
||||
nix develop
|
||||
```
|
||||
This will open a shell with all dependencies and environment configured as per the `flake.nix` for (`x86_64-linux`) systems only at this time.
|
||||
|
||||
---
|
||||
### 2. Using `nix-shell` (that's why shell.nix is a separate file)
|
||||
If you want to use traditional `nix-shell` tooling which uses the nixpkgs version of your system:
|
||||
```
|
||||
nix-shell
|
||||
```
|
||||
This will drop you into the shell environment defined in `shell.nix`. Note that this is not flake-native method and does not use the locked nixpkgs in `flake.lock` so exact versions of the dependancies is not guaranteed.
|
||||
|
||||
---
|
||||
## What’s inside the dev shell?
|
||||
- The environment variables and packages configured in `shell.nix` will be available.
|
||||
- The package set (`pkgs`) used aligns with the versions locked in `flake.lock` to ensure reproducibility.
|
||||
|
||||
---
|
||||
## Example Workflow using flakes
|
||||
```
|
||||
# Navigate to the project root folder which contains the flake.nix, flake.lock and shell.nix files.
|
||||
cd /home/user/dev/Libation
|
||||
# Enter the flake development shell (Linux x86_64)
|
||||
nix develop
|
||||
# run VSCode or VSCodium from the current shell environment
|
||||
code .
|
||||
# Run or Debug using VSCode and VSCodium using the linux Launch configuration.
|
||||
```
|
||||

|
||||
|
||||
You can also Build and run your application inside the shell.
|
||||
```
|
||||
dotnet build ./Source/LibationAvalonia/LibationAvalonia.csproj -p:TargetFrameworks=net9.0 -p:TargetFramework=net9.0 -p:RuntimeIdentifier=linux-x64
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Notes
|
||||
- Leaving the current shell environemnt will drop all added dependancies and you will not be able to run or debug the program unless your system has those dependancies defined globally.
|
||||
- To exit the shell environment voluntarily use `exit` inside the shell.
|
||||
- Ensure you have no conflicting `nix.conf` or `global.json` that might affect SDK versions or runtime identifiers.
|
||||
- Keep your `flake.lock` file committed to ensure builds are reproducible for all collaborators.
|
||||
|
||||
---
|
||||
## References
|
||||
|
||||
- [Nix Flakes - NixOS Wiki](https://nixos.wiki/wiki/Flakes)
|
||||
- [Nix.dev - Introduction to Nix flakes](https://nix.dev/manual/nix/2.28/command-ref/new-cli/nix3-flake-init)
|
||||
- [Nix-shell Manual](https://nixos.org/manual/nix/stable/command-ref/nix-shell.html)
|
||||
@ -81,17 +81,39 @@ Anything between the opening tag (`<tagname->`) and closing tag (`<-tagname>`) w
|
||||
|\<if podcast-\>...\<-if podcast\>|Only include if part of a podcast|Conditional|
|
||||
|\<if bookseries-\>...\<-if bookseries\>|Only include if part of a book series|Conditional|
|
||||
|\<if podcastparent-\>...\<-if podcastparent\>**†**|Only include if item is a podcast series parent|Conditional|
|
||||
|\<has PROPERTY-\>...\<-has\>|Only include if the PROPERTY has a value (i.e. not null or empty)|Conditional|
|
||||
|
||||
**†** Only affects the podcast series folder naming if "Save all podcast episodes to the series parent folder" option is checked.
|
||||
|
||||
For example, <if podcast-\>\<series\>\<-if podcast\> will evaluate to the podcast's series name if the file is a podcast. For audiobooks that are not podcasts, that tag will be blank.
|
||||
For example, `<if podcast-><series><-if podcast>` will evaluate to the podcast's series name if the file is a podcast. For audiobooks that are not podcasts, that tag will be blank.
|
||||
|
||||
You can invert the condition (instead of displaying the text when the condition is true, display the text when it is false) by playing a '!' symbol before the opening tag name.
|
||||
You can invert the condition (instead of displaying the text when the condition is true, display the text when it is false) by playing a `!` symbol before the opening tag name.
|
||||
|
||||
|Inverted Tag|Description|Type|
|
||||
|-|-|-|
|
||||
|\<!if series-\>...\<-if series\>|Only include if *not* part of a book series or podcast|Conditional|
|
||||
|\<!if podcast-\>...\<-if podcast\>|Only include if *not* part of a podcast|Conditional|
|
||||
|\<!if bookseries-\>...\<-if bookseries\>|Only include if *not* part of a book series|Conditional|
|
||||
|\<!if podcastparent-\>...\<-if podcastparent\>**†**|Only include if item is *not* a podcast series parent|Conditional|
|
||||
|\<!has PROPERTY-\>...\<-has\>|Only include if the PROPERTY *does not* have a value (i.e. is null or empty)|Conditional|
|
||||
|
||||
**†** Only affects the podcast series folder naming if "Save all podcast episodes to the series parent folder" option is checked.
|
||||
|
||||
As an example, this folder template will place all Liberated podcasts into a "Podcasts" folder and all liberated books (not podcasts) into a "Books" folder.
|
||||
|
||||
\<if podcast-\>Podcasts<-if podcast\>\<!if podcast-\>Books\<-if podcast\>\\\<title\>
|
||||
`<if podcast->Podcasts<-if podcast><!if podcast->Books<-if podcast>\<title>`
|
||||
|
||||
This example will add a number if the `<series#\>` tag has a value:
|
||||
|
||||
`<has series#><series#><-has>`
|
||||
|
||||
This example will put non-series books in a "Standalones" folder:
|
||||
|
||||
`<!if series->Standalones/<-if series>`
|
||||
|
||||
And this example will customize the title based on whether the book has a subtitle:
|
||||
|
||||
`<audible title><has audible subtitle->-<audible subtitle><-has>`
|
||||
|
||||
# Tag Formatters
|
||||
**Text**, **Name List**, **Number**, and **DateTime** tags can be optionally formatted using format text in square brackets after the tag name. Below is a list of supported formatters for each tag type.
|
||||
@ -105,13 +127,13 @@ As an example, this folder template will place all Liberated podcasts into a "Po
|
||||
## Series Formatters
|
||||
|Formatter|Description|Example Usage|Example Result|
|
||||
|-|-|-|-|
|
||||
|\{N \| # \| ID\}|Formats the series using<br>the series part tags.<br>\{N\} = Series Name<br>\{#\} = Number order in series<br>\{ID\} = Audible Series ID<br><br>Default is \{N\}|`<first series>`<hr>`<first series[{N}]>`<hr>`<first series[{N}, {#}, {ID}]>`|Sherlock Holmes<hr>Sherlock Holmes<hr>Sherlock Holmes, 1, B08376S3R2|
|
||||
|\{N \| # \| ID\}|Formats the series using<br>the series part tags.<br>\{N\} = Series Name<br>\{#\} = Number order in series<br>\{#:[Number_Formatter](#number-formatters)\} = Number order in series, formatted<br>\{ID\} = Audible Series ID<br><br>Default is \{N\}|`<first series>`<hr>`<first series[{N}]>`<hr>`<first series[{N}, {#}, {ID}]>`<hr>`<first series[{N}, {ID}, {#:00.0}]>`|Sherlock Holmes<hr>Sherlock Holmes<hr>Sherlock Holmes, 1-6, B08376S3R2<hr>Sherlock Holmes, B08376S3R2, 01.0-06.0|
|
||||
|
||||
## Series List Formatters
|
||||
|Formatter|Description|Example Usage|Example Result|
|
||||
|-|-|-|-|
|
||||
|separator()|Speficy the text used to join<br>multiple series names.<br><br>Default is ", "|`<series[separator(; )]>`|Sherlock Holmes; Some Other Series|
|
||||
|format(\{N \| # \| ID\})|Formats the series properties<br>using the name series tags.<br>See [Series Formatter Usage](#series-formatters) above.|`<series[format({N}, {#})`<br>`separator(; )]>`<hr>`<author[format({L}, {ID}) separator(; )]>`|Sherlock Holmes, 1; Some Other Series, 1<hr>herlock Holmes, B08376S3R2; Some Other Series, B000000000|
|
||||
|format(\{N \| # \| ID\})|Formats the series properties<br>using the name series tags.<br>See [Series Formatter Usage](#series-formatters) above.|`<series[format({N}, {#})`<br>`separator(; )]>`<hr>`<series[format({ID}-{N}, {#:00.0})]>`|Sherlock Holmes, 1-6; Book Collection, 1<hr>B08376S3R2-Sherlock Holmes, 01.0-06.0, B000000000-Book Collection, 01.0|
|
||||
|max(#)|Only use the first # of series<br><br>Default is all series|`<series[max(1)]>`|Sherlock Holmes|
|
||||
|
||||
## Name Formatters
|
||||
|
||||
BIN
Documentation/images/AudioFormatSettings.png
Normal file
BIN
Documentation/images/AudioFormatSettings.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
Documentation/images/StartingDebuggingInVSCode.png
Normal file
BIN
Documentation/images/StartingDebuggingInVSCode.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
@ -34,6 +34,7 @@
|
||||
- [Custom File Naming](Documentation/NamingTemplates.md)
|
||||
- [Command Line Interface](Documentation/Advanced.md#command-line-interface)
|
||||
- [Custom Theme Colors](Documentation/Advanced.md#custom-theme-colors) (Chardonnay Only)
|
||||
- [Audio Formats (Dolby Atmos, Widevine, Spacial Audio)](Documentation/AudioFileFormats.md)
|
||||
- [Docker](Documentation/Docker.md)
|
||||
- [Frequently Asked Questions](Documentation/FrequentlyAskedQuestions.md)
|
||||
|
||||
|
||||
@ -126,8 +126,8 @@ namespace AaxDecrypter
|
||||
if (DownloadOptions.SeriesName is string series)
|
||||
AaxFile.AppleTags.AppleListBox.EditOrAddFreeformTag(tagDomain, "SERIES", series);
|
||||
|
||||
if (DownloadOptions.SeriesNumber is float part)
|
||||
AaxFile.AppleTags.AppleListBox.EditOrAddFreeformTag(tagDomain, "PART", part.ToString());
|
||||
if (DownloadOptions.SeriesNumber is string part)
|
||||
AaxFile.AppleTags.AppleListBox.EditOrAddFreeformTag(tagDomain, "PART", part);
|
||||
}
|
||||
|
||||
OnRetrievedTitle(AaxFile.AppleTags.TitleSansUnabridged);
|
||||
|
||||
@ -43,7 +43,7 @@ namespace AaxDecrypter
|
||||
string? Publisher { get; }
|
||||
string? Language { get; }
|
||||
string? SeriesName { get; }
|
||||
float? SeriesNumber { get; }
|
||||
string? SeriesNumber { get; }
|
||||
NAudio.Lame.LameConfig? LameConfig { get; }
|
||||
bool Downsample { get; }
|
||||
bool MatchSourceBitrate { get; }
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<Version>12.4.10.2</Version>
|
||||
<Version>12.5.3.1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Octokit" Version="14.0.0" />
|
||||
|
||||
@ -121,7 +121,7 @@ namespace AppScaffolding
|
||||
zipFileSink["Name"] = "File";
|
||||
fileChanged = true;
|
||||
}
|
||||
var hooks = $"{nameof(LibationFileManager)}.{nameof(FileSinkHook)}, {nameof(LibationFileManager)}";
|
||||
var hooks = typeof(FileSinkHook).AssemblyQualifiedName;
|
||||
if (serilog.SelectToken("$.WriteTo[?(@.Name == 'File')].Args", false) is JObject fileSinkArgs
|
||||
&& fileSinkArgs["hooks"]?.Value<string>() != hooks)
|
||||
{
|
||||
@ -158,7 +158,8 @@ namespace AppScaffolding
|
||||
// - with class and method info: "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] (at {Caller}) {Message:lj}{NewLine}{Exception}";
|
||||
// output example: 2019-11-26 08:48:40.224 -05:00 [DBG] (at LibationWinForms.Program.init()) Begin Libation
|
||||
// {Properties:j} needed for expanded exception logging
|
||||
{ "outputTemplate", "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] (at {Caller}) {Message:lj}{NewLine}{Exception} {Properties:j}" }
|
||||
{ "outputTemplate", "{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz} [{Level:u3}] (at {Caller}) {Message:lj}{NewLine}{Exception} {Properties:j}" },
|
||||
{ "hooks", typeof(FileSinkHook).AssemblyQualifiedName }, // for FileSinkHook
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,8 +5,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AudibleApi" Version="9.4.2.1" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.31.1" />
|
||||
<PackageReference Include="AudibleApi" Version="9.4.5.1" />
|
||||
<PackageReference Include="Google.Protobuf" Version="3.32.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Numerics;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
#nullable enable
|
||||
@ -56,18 +57,99 @@ internal class Device
|
||||
|
||||
public byte[] SignMessage(byte[] message)
|
||||
{
|
||||
using var sha1 = SHA1.Create();
|
||||
var digestion = sha1.ComputeHash(message);
|
||||
return CdmKey.SignHash(digestion, HashAlgorithmName.SHA1, RSASignaturePadding.Pss);
|
||||
var digestion = SHA1.HashData(message);
|
||||
return PssSha1Signer.SignHash(CdmKey, digestion);
|
||||
}
|
||||
|
||||
public bool VerifyMessage(byte[] message, byte[] signature)
|
||||
{
|
||||
using var sha1 = SHA1.Create();
|
||||
var digestion = sha1.ComputeHash(message);
|
||||
var digestion = SHA1.HashData(message);
|
||||
return CdmKey.VerifyHash(digestion, signature, HashAlgorithmName.SHA1, RSASignaturePadding.Pss);
|
||||
}
|
||||
|
||||
public byte[] DecryptSessionKey(byte[] sessionKey)
|
||||
=> CdmKey.Decrypt(sessionKey, RSAEncryptionPadding.OaepSHA1);
|
||||
|
||||
/// <summary>
|
||||
/// Completely managed implementation of RSASSA-PSS using SHA-1.
|
||||
/// https://github.com/bcgit/bc-csharp/blob/master/crypto/src/crypto/signers/PssSigner.cs
|
||||
///
|
||||
/// Absolutely nobody anywhere should use this RSASSA-PSS implementation in anything where they care about security at all. We completely skipped the random salt part of it because libation doesn't need security; it only needs to satisfy Audible server's challenge-response requirements.
|
||||
/// </summary>
|
||||
private static class PssSha1Signer
|
||||
{
|
||||
private const int Sha1DigestSize = 20;
|
||||
private const int Trailer = 0xBC;
|
||||
|
||||
public static byte[] SignHash(RSA rsa, ReadOnlySpan<byte> hash)
|
||||
{
|
||||
ArgumentOutOfRangeException.ThrowIfNotEqual(hash.Length, Sha1DigestSize);
|
||||
|
||||
var parameters = rsa.ExportParameters(true);
|
||||
var Modulus = new BigInteger(parameters.Modulus, isUnsigned: true, isBigEndian: true);
|
||||
var Exponent = new BigInteger(parameters.D, isUnsigned: true, isBigEndian: true);
|
||||
var emBits = rsa.KeySize - 1;
|
||||
var block = new byte[(emBits + 7) / 8];
|
||||
var firstByteMask = (byte)(0xFFU >> ((block.Length * 8) - emBits));
|
||||
|
||||
Span<byte> mDash = new byte[8 + 2 * Sha1DigestSize];
|
||||
|
||||
hash.CopyTo(mDash.Slice(8));
|
||||
var h = SHA1.HashData(mDash);
|
||||
|
||||
block[^(2 * (Sha1DigestSize + 1))] = 1;
|
||||
byte[] dbMask = MaskGeneratorFunction1(h, 0, h.Length, block.Length - Sha1DigestSize - 1);
|
||||
for (int i = 0; i != dbMask.Length; i++)
|
||||
block[i] ^= dbMask[i];
|
||||
|
||||
h.CopyTo(block, block.Length - Sha1DigestSize - 1);
|
||||
|
||||
block[0] &= firstByteMask;
|
||||
block[^1] = Trailer;
|
||||
|
||||
var input = new BigInteger(block, isUnsigned: true, isBigEndian: true);
|
||||
var result = BigInteger.ModPow(input, Exponent, Modulus);
|
||||
return result.ToByteArray(isUnsigned: true, isBigEndian: true);
|
||||
}
|
||||
|
||||
private static byte[] MaskGeneratorFunction1(byte[] Z, int zOff, int zLen, int length)
|
||||
{
|
||||
byte[] mask = new byte[length];
|
||||
byte[] hashBuf = new byte[Sha1DigestSize];
|
||||
byte[] C = new byte[4];
|
||||
int counter = 0;
|
||||
|
||||
using var sha = SHA1.Create();
|
||||
|
||||
for (; counter < (length / Sha1DigestSize); counter++)
|
||||
{
|
||||
ItoOSP(counter, C);
|
||||
|
||||
sha.TransformBlock(Z, zOff, zLen, null, 0);
|
||||
sha.TransformFinalBlock(C, 0, C.Length);
|
||||
|
||||
sha.Hash!.CopyTo(mask, counter * Sha1DigestSize);
|
||||
}
|
||||
|
||||
if ((counter * Sha1DigestSize) < length)
|
||||
{
|
||||
ItoOSP(counter, C);
|
||||
|
||||
sha.TransformBlock(Z, zOff, zLen, null, 0);
|
||||
sha.TransformFinalBlock(C, 0, C.Length);
|
||||
|
||||
Array.Copy(sha.Hash!, 0, mask, counter * Sha1DigestSize, mask.Length - (counter * Sha1DigestSize));
|
||||
}
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
private static void ItoOSP(int i, byte[] sp)
|
||||
{
|
||||
sp[0] = (byte)((uint)i >> 24);
|
||||
sp[1] = (byte)((uint)i >> 16);
|
||||
sp[2] = (byte)((uint)i >> 8);
|
||||
sp[3] = (byte)((uint)i >> 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,14 +10,14 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dinah.Core" Version="9.0.1.1" />
|
||||
<PackageReference Include="Dinah.Core" Version="9.0.3.1" />
|
||||
<PackageReference Include="Dinah.EntityFrameworkCore" Version="9.0.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.7">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.7" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.7">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.8" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.8">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
|
||||
@ -241,7 +241,7 @@ namespace DataLayer
|
||||
{
|
||||
// don't overwrite with default values
|
||||
IsAbridged |= isAbridged;
|
||||
IsSpatial |= isSpatial ?? false;
|
||||
IsSpatial = isSpatial ?? IsSpatial;
|
||||
DatePublished = datePublished ?? DatePublished;
|
||||
Language = language?.FirstCharToUpper() ?? Language;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
#nullable enable
|
||||
namespace DataLayer
|
||||
{
|
||||
// only library importing should use tracking. All else should be NoTracking.
|
||||
@ -24,13 +25,13 @@ namespace DataLayer
|
||||
.Where(c => !c.Book.IsEpisodeParent() || includeParents)
|
||||
.ToList();
|
||||
|
||||
public static LibraryBook GetLibraryBook_Flat_NoTracking(this LibationContext context, string productId)
|
||||
public static LibraryBook? GetLibraryBook_Flat_NoTracking(this LibationContext context, string productId)
|
||||
=> context
|
||||
.LibraryBooks
|
||||
.AsNoTrackingWithIdentityResolution()
|
||||
.GetLibraryBook(productId);
|
||||
|
||||
public static LibraryBook GetLibraryBook(this IQueryable<LibraryBook> library, string productId)
|
||||
public static LibraryBook? GetLibraryBook(this IQueryable<LibraryBook> library, string productId)
|
||||
=> library
|
||||
.GetLibrary()
|
||||
.SingleOrDefault(lb => lb.Book.AudibleProductId == productId);
|
||||
|
||||
@ -18,9 +18,6 @@ namespace FileLiberator;
|
||||
|
||||
public partial class DownloadOptions
|
||||
{
|
||||
private const string Ec3Codec = "ec+3";
|
||||
private const string Ac4Codec = "ac-4";
|
||||
|
||||
/// <summary>
|
||||
/// Initiate an audiobook download from the audible api.
|
||||
/// </summary>
|
||||
@ -71,8 +68,10 @@ public partial class DownloadOptions
|
||||
token.ThrowIfCancellationRequested();
|
||||
try
|
||||
{
|
||||
//try to request a widevine content license using the user's spatial audio settings
|
||||
var codecChoice = config.SpatialAudioCodec is Configuration.SpatialCodec.AC_4 ? Ac4Codec : Ec3Codec;
|
||||
//try to request a widevine content license using the user's audio settings
|
||||
var aacCodecChoice = config.Request_xHE_AAC ? Codecs.xHE_AAC : Codecs.AAC_LC;
|
||||
//Always use the ec+3 codec if converting to mp3
|
||||
var spatialCodecChoice = config.SpatialAudioCodec is Configuration.SpatialCodec.AC_4 && !config.DecryptToLossy ? Codecs.AC_4 : Codecs.EC_3;
|
||||
|
||||
var contentLic
|
||||
= await api.GetDownloadLicenseAsync(
|
||||
@ -81,7 +80,8 @@ public partial class DownloadOptions
|
||||
ChapterTitlesType.Tree,
|
||||
DrmType.Widevine,
|
||||
config.RequestSpatial,
|
||||
codecChoice);
|
||||
aacCodecChoice,
|
||||
spatialCodecChoice);
|
||||
|
||||
if (contentLic.DrmType is not DrmType.Widevine)
|
||||
return new LicenseInfo(contentLic);
|
||||
|
||||
@ -26,7 +26,7 @@ namespace FileLiberator
|
||||
public string Language => LibraryBook.Book.Language;
|
||||
public string? AudibleProductId => LibraryBookDto.AudibleProductId;
|
||||
public string? SeriesName => LibraryBookDto.FirstSeries?.Name;
|
||||
public float? SeriesNumber => LibraryBookDto.FirstSeries?.Number;
|
||||
public string? SeriesNumber => LibraryBookDto.FirstSeries?.Order?.ToString();
|
||||
public NAudio.Lame.LameConfig? LameConfig { get; }
|
||||
public string UserAgent => AudibleApi.Resources.Download_User_Agent;
|
||||
public bool StripUnabridged => Config.AllowLibationFixup && Config.StripUnabridged;
|
||||
@ -74,7 +74,7 @@ namespace FileLiberator
|
||||
//If DrmType is not Adrm or Widevine, the delivered file is an unencrypted mp3.
|
||||
OutputFormat
|
||||
= licInfo.DrmType is not AudibleApi.Common.DrmType.Adrm and not AudibleApi.Common.DrmType.Widevine ||
|
||||
(config.AllowLibationFixup && config.DecryptToLossy && licInfo.ContentMetadata.ContentReference.Codec != Ac4Codec)
|
||||
(config.AllowLibationFixup && config.DecryptToLossy && licInfo.ContentMetadata.ContentReference.Codec != AudibleApi.Codecs.AC_4)
|
||||
? OutputFormat.Mp3
|
||||
: OutputFormat.M4b;
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ using System.Threading.Tasks;
|
||||
using AudibleUtilities;
|
||||
using DataLayer;
|
||||
using Dinah.Core;
|
||||
using LibationFileManager;
|
||||
using LibationFileManager.Templates;
|
||||
|
||||
#nullable enable
|
||||
@ -66,7 +67,7 @@ namespace FileLiberator
|
||||
BitRate = libraryBook.Book.UserDefinedItem.LastDownloadedFormat?.BitRate,
|
||||
SampleRate = libraryBook.Book.UserDefinedItem.LastDownloadedFormat?.SampleRate,
|
||||
Channels = libraryBook.Book.UserDefinedItem.LastDownloadedFormat?.ChannelCount,
|
||||
LibationVersion = libraryBook.Book.UserDefinedItem.LastDownloadedVersion?.ToString(3),
|
||||
LibationVersion = libraryBook.Book.UserDefinedItem.LastDownloadedVersion?.ToVersionString(),
|
||||
FileVersion = libraryBook.Book.UserDefinedItem.LastDownloadedFileVersion
|
||||
};
|
||||
}
|
||||
@ -82,7 +83,7 @@ namespace FileLiberator
|
||||
.Select(sb
|
||||
=> new SeriesDto(
|
||||
sb.Series.Name,
|
||||
sb.Book.IsEpisodeParent() ? null : sb.Index,
|
||||
sb.Book.IsEpisodeParent() ? null : sb.Order,
|
||||
sb.Series.AudibleSeriesId)
|
||||
).ToList();
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dinah.Core" Version="9.0.1.1" />
|
||||
<PackageReference Include="Dinah.Core" Version="9.0.3.1" />
|
||||
<PackageReference Include="Polly" Version="8.6.2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
74
Source/FileManager/FileSystemTest.cs
Normal file
74
Source/FileManager/FileSystemTest.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace FileManager
|
||||
{
|
||||
public static class FileSystemTest
|
||||
{
|
||||
/// <summary>
|
||||
/// Additional characters which are illegal for filenames in Windows environments.
|
||||
/// Double quotes and slashes are already illegal filename characters on all platforms,
|
||||
/// so they are not included here.
|
||||
/// </summary>
|
||||
public static string AdditionalInvalidWindowsFilenameCharacters { get; } = "<>|:*?";
|
||||
|
||||
/// <summary>
|
||||
/// Test if the directory supports filenames with characters that are invalid on Windows (:, *, ?, <, >, |).
|
||||
/// </summary>
|
||||
public static bool CanWriteWindowsInvalidChars(LongPath directoryName)
|
||||
{
|
||||
var testFile = Path.Combine(directoryName, AdditionalInvalidWindowsFilenameCharacters + Guid.NewGuid().ToString());
|
||||
return CanWriteFile(testFile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if the directory supports filenames with 255 unicode characters.
|
||||
/// </summary>
|
||||
public static bool CanWrite255UnicodeChars(LongPath directoryName)
|
||||
{
|
||||
const char unicodeChar = 'ü';
|
||||
var testFileName = new string(unicodeChar, 255);
|
||||
var testFile = Path.Combine(directoryName, testFileName);
|
||||
return CanWriteFile(testFile);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test if a directory has write access by attempting to create an empty file in it.
|
||||
/// <para/>Returns true even if the temporary file can not be deleted.
|
||||
/// </summary>
|
||||
public static bool CanWriteDirectory(LongPath directoryName)
|
||||
{
|
||||
if (!Directory.Exists(directoryName))
|
||||
return false;
|
||||
|
||||
Serilog.Log.Logger.Debug("Testing write permissions for directory: {@DirectoryName}", directoryName);
|
||||
var testFilePath = Path.Combine(directoryName, Guid.NewGuid().ToString());
|
||||
return CanWriteFile(testFilePath);
|
||||
}
|
||||
|
||||
private static bool CanWriteFile(LongPath filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
Serilog.Log.Logger.Debug("Testing ability to write filename: {@filename}", filename);
|
||||
File.WriteAllBytes(filename, []);
|
||||
Serilog.Log.Logger.Debug("Deleting test file after successful write: {@filename}", filename);
|
||||
try
|
||||
{
|
||||
FileUtility.SaferDelete(filename);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//An error deleting the file doesn't constitute a write failure.
|
||||
Serilog.Log.Logger.Debug(ex, "Error deleting test file: {@filename}", filename);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Debug(ex, "Error writing test file: {@filename}", filename);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -56,7 +56,7 @@ namespace FileManager
|
||||
{
|
||||
ArgumentValidator.EnsureNotNull(name, nameof(name));
|
||||
|
||||
name = ReplacementCharacters.Barebones.ReplaceFilenameChars(name);
|
||||
name = ReplacementCharacters.Barebones(true).ReplaceFilenameChars(name);
|
||||
return Task.Run(() => AddFileInternal(name, contents.Span, comment));
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,8 @@ internal interface IClosingPropertyTag : IPropertyTag
|
||||
bool StartsWithClosing(string templateString, [NotNullWhen(true)] out string? exactName, [NotNullWhen(true)] out IClosingPropertyTag? propertyTag);
|
||||
}
|
||||
|
||||
public delegate bool Conditional<T>(ITemplateTag templateTag, T value, string condition);
|
||||
|
||||
public class ConditionalTagCollection<TClass> : TagCollection
|
||||
{
|
||||
public ConditionalTagCollection(bool caseSensative = true) :base(typeof(TClass), caseSensative) { }
|
||||
@ -32,21 +34,49 @@ public class ConditionalTagCollection<TClass> : TagCollection
|
||||
/// <param name="propertyGetter">A Func to get the condition's <see cref="bool"/> value from <see cref="TClass"/></param>
|
||||
public void Add(ITemplateTag templateTag, Func<TClass, bool> propertyGetter)
|
||||
{
|
||||
var expr = Expression.Call(Expression.Constant(propertyGetter.Target), propertyGetter.Method, Parameter);
|
||||
|
||||
var target = propertyGetter.Target is null ? null : Expression.Constant(propertyGetter.Target);
|
||||
var expr = Expression.Call(target, propertyGetter.Method, Parameter);
|
||||
AddPropertyTag(new ConditionalTag(templateTag, Options, expr));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a conditional tag.
|
||||
/// </summary>
|
||||
/// <param name="conditional">A <see cref="Conditional{TClass}"/> to get the condition's <see cref="bool"/> value</param>
|
||||
public void Add(ITemplateTag templateTag, Conditional<TClass> conditional)
|
||||
{
|
||||
AddPropertyTag(new ConditionalTag(templateTag, Options, Parameter, conditional));
|
||||
}
|
||||
|
||||
private class ConditionalTag : TagBase, IClosingPropertyTag
|
||||
{
|
||||
public override Regex NameMatcher { get; }
|
||||
public Regex NameCloseMatcher { get; }
|
||||
|
||||
private Func<string?, Expression> CreateConditionExpression { get; }
|
||||
|
||||
public ConditionalTag(ITemplateTag templateTag, RegexOptions options, Expression conditionExpression)
|
||||
: base(templateTag, conditionExpression)
|
||||
{
|
||||
NameMatcher = new Regex($"^<(!)?{templateTag.TagName}->", options);
|
||||
NameMatcher = new Regex(@$"^<(!)?{templateTag.TagName}->", options);
|
||||
NameCloseMatcher = new Regex($"^<-{templateTag.TagName}>", options);
|
||||
CreateConditionExpression = _ => conditionExpression;
|
||||
}
|
||||
|
||||
public ConditionalTag(ITemplateTag templateTag, RegexOptions options, ParameterExpression parameter, Conditional<TClass> conditional)
|
||||
: base(templateTag, Expression.Constant(false))
|
||||
{
|
||||
NameMatcher = new Regex(@$"^<(!)?{templateTag.TagName}(?:\s+?(.*?)\s*?)?->", options);
|
||||
NameCloseMatcher = new Regex($"^<-{templateTag.TagName}>", options);
|
||||
|
||||
var target = conditional.Target is null ? null : Expression.Constant(conditional.Target);
|
||||
CreateConditionExpression = condition
|
||||
=> Expression.Call(
|
||||
conditional.Target is null ? null : Expression.Constant(conditional.Target),
|
||||
conditional.Method,
|
||||
Expression.Constant(templateTag),
|
||||
parameter,
|
||||
Expression.Constant(condition));
|
||||
}
|
||||
|
||||
public bool StartsWithClosing(string templateString, [NotNullWhen(true)] out string? exactName, [NotNullWhen(true)] out IClosingPropertyTag? propertyTag)
|
||||
@ -64,6 +94,13 @@ public class ConditionalTagCollection<TClass> : TagCollection
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override Expression GetTagExpression(string exactName, string formatter) => formatter == "!" ? Expression.Not(ValueExpression) : ValueExpression;
|
||||
protected override Expression GetTagExpression(string exactName, string[] extraData)
|
||||
{
|
||||
if (extraData.Length is not (1 or 2) || extraData[0] is not ("!" or "") || extraData.Length == 2 && string.IsNullOrWhiteSpace(extraData[1]))
|
||||
return Expression.Constant(false);
|
||||
|
||||
var getBool = extraData.Length == 2 ? CreateConditionExpression(extraData[1]) : CreateConditionExpression(null);
|
||||
return extraData[0] == "!" ? Expression.Not(getBool) : getBool;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ public class NamingTemplate
|
||||
/// Invoke the <see cref="NamingTemplate"/>
|
||||
/// </summary>
|
||||
/// <param name="propertyClasses">Instances of the TClass used in <see cref="PropertyTagCollection{TClass}"/> and <see cref="ConditionalTagCollection{TClass}"/></param>
|
||||
public TemplatePart Evaluate(params object[] propertyClasses)
|
||||
public TemplatePart Evaluate(params object?[] propertyClasses)
|
||||
{
|
||||
if (templateToString is null)
|
||||
throw new InvalidOperationException();
|
||||
@ -39,7 +39,7 @@ public class NamingTemplate
|
||||
// First parameter is "this", so ignore it.
|
||||
var delegateArgTypes = templateToString.Method.GetParameters().Skip(1);
|
||||
|
||||
object[] args = delegateArgTypes.Join(propertyClasses, o => o.ParameterType, i => i.GetType(), (_, i) => i).ToArray();
|
||||
object?[] args = delegateArgTypes.Join(propertyClasses, o => o.ParameterType, i => i?.GetType(), (_, i) => i).ToArray();
|
||||
|
||||
if (args.Length != delegateArgTypes.Count())
|
||||
throw new ArgumentException($"This instance of {nameof(NamingTemplate)} requires the following arguments: {string.Join(", ", delegateArgTypes.Select(t => t.Name).Distinct())}");
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using Dinah.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text.RegularExpressions;
|
||||
@ -109,6 +110,25 @@ public class PropertyTagCollection<TClass> : TagCollection
|
||||
catch { return null; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to get the default (unformatted) value of a property tag.
|
||||
/// </summary>
|
||||
/// <param name="tagName">Name of the tag value to get</param>
|
||||
/// <param name="object">The property class from which the tag's value is read</param>
|
||||
/// <param name="value"><paramref name="tagName"/>'s string value if it is in this collection, otherwise null</param>
|
||||
/// <returns>True if the <paramref name="tagName"/> is in this collection, otherwise false</returns>
|
||||
public bool TryGetValue(string tagName, TClass @object, [NotNullWhen(true)] out string? value)
|
||||
{
|
||||
value = null;
|
||||
|
||||
if (!StartsWith($"<{tagName}>", out var exactName, out var propertyTag, out var valueExpression))
|
||||
return false;
|
||||
|
||||
var func = Expression.Lambda<Func<TClass, string>>(valueExpression, Parameter).Compile();
|
||||
value = func(@object);
|
||||
return true;
|
||||
}
|
||||
|
||||
private class PropertyTag<TPropertyValue> : TagBase
|
||||
{
|
||||
public override Regex NameMatcher { get; }
|
||||
@ -138,8 +158,13 @@ public class PropertyTagCollection<TClass> : TagCollection
|
||||
expVal);
|
||||
}
|
||||
|
||||
protected override Expression GetTagExpression(string exactName, string formatString)
|
||||
protected override Expression GetTagExpression(string exactName, string[] extraData)
|
||||
{
|
||||
if (extraData.Length is not (0 or 1))
|
||||
return Expression.Constant(exactName);
|
||||
|
||||
string formatString = extraData.Length == 1 ? extraData[0] : "";
|
||||
|
||||
Expression toStringExpression
|
||||
= !ReturnType.IsValueType
|
||||
? Expression.Condition(
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@ -42,8 +43,8 @@ internal abstract class TagBase : IPropertyTag
|
||||
|
||||
/// <summary>Create an <see cref="Expression"/> that returns the property's value.</summary>
|
||||
/// <param name="exactName">The exact string that was matched to <see cref="ITemplateTag"/></param>
|
||||
/// <param name="formatter">The optional format string in the match inside the square brackets</param>
|
||||
protected abstract Expression GetTagExpression(string exactName, string formatter);
|
||||
/// <param name="extraData">Optional extra data parsed from the tag, such as a format string in the match the square brackets, logical negation, and conditional options</param>
|
||||
protected abstract Expression GetTagExpression(string exactName, string[] extraData);
|
||||
|
||||
public bool StartsWith(string templateString, [NotNullWhen(true)] out string? exactName, [NotNullWhen(true)] out Expression? propertyValue)
|
||||
{
|
||||
@ -51,7 +52,7 @@ internal abstract class TagBase : IPropertyTag
|
||||
if (match.Success)
|
||||
{
|
||||
exactName = match.Value;
|
||||
propertyValue = GetTagExpression(exactName, match.Groups.Count == 2 ? match.Groups[1].Value.Trim() : "");
|
||||
propertyValue = GetTagExpression(exactName, match.Groups.Values.Skip(1).Select(v => v.Value.Trim()).ToArray());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -18,7 +18,7 @@ public abstract class TagCollection : IEnumerable<ITemplateTag>
|
||||
/// <summary>The <see cref="ParameterExpression"/> of the <see cref="TagCollection"/>'s TClass type.</summary>
|
||||
internal ParameterExpression Parameter { get; }
|
||||
protected RegexOptions Options { get; } = RegexOptions.Compiled;
|
||||
private List<IPropertyTag> PropertyTags { get; } = new();
|
||||
internal List<IPropertyTag> PropertyTags { get; } = new();
|
||||
|
||||
protected TagCollection(Type classType, bool caseSensative = true)
|
||||
{
|
||||
|
||||
@ -74,12 +74,14 @@ namespace FileManager
|
||||
}
|
||||
public override int GetHashCode() => Replacements.GetHashCode();
|
||||
|
||||
public static readonly ReplacementCharacters Default
|
||||
= IsWindows
|
||||
? new()
|
||||
{
|
||||
Replacements = new Replacement[]
|
||||
public static ReplacementCharacters Default(bool ntfs) => ntfs ? HiFi_NTFS : HiFi_Other;
|
||||
public static ReplacementCharacters LoFiDefault(bool ntfs) => ntfs ? LoFi_NTFS : LoFi_Other;
|
||||
public static ReplacementCharacters Barebones(bool ntfs) => ntfs ? BareBones_NTFS : BareBones_Other;
|
||||
|
||||
#region Defaults
|
||||
private static readonly ReplacementCharacters HiFi_NTFS = new()
|
||||
{
|
||||
Replacements = [
|
||||
Replacement.OtherInvalid("_"),
|
||||
Replacement.FilenameForwardSlash("∕"),
|
||||
Replacement.FilenameBackSlash(""),
|
||||
@ -91,28 +93,23 @@ namespace FileManager
|
||||
Replacement.Colon("_"),
|
||||
Replacement.Asterisk("✱"),
|
||||
Replacement.QuestionMark("?"),
|
||||
Replacement.Pipe("⏐"),
|
||||
}
|
||||
}
|
||||
: new()
|
||||
{
|
||||
Replacements = new Replacement[]
|
||||
Replacement.Pipe("⏐")]
|
||||
};
|
||||
|
||||
private static readonly ReplacementCharacters HiFi_Other = new()
|
||||
{
|
||||
Replacements = [
|
||||
Replacement.OtherInvalid("_"),
|
||||
Replacement.FilenameForwardSlash("∕"),
|
||||
Replacement.FilenameBackSlash("\\"),
|
||||
Replacement.OpenQuote("“"),
|
||||
Replacement.CloseQuote("”"),
|
||||
Replacement.OtherQuote("\"")
|
||||
}
|
||||
Replacement.OtherQuote("\"")]
|
||||
};
|
||||
|
||||
public static readonly ReplacementCharacters LoFiDefault
|
||||
= IsWindows
|
||||
? new()
|
||||
{
|
||||
Replacements = new Replacement[]
|
||||
private static readonly ReplacementCharacters LoFi_NTFS = new()
|
||||
{
|
||||
Replacements = [
|
||||
Replacement.OtherInvalid("_"),
|
||||
Replacement.FilenameForwardSlash("_"),
|
||||
Replacement.FilenameBackSlash("_"),
|
||||
@ -121,56 +118,54 @@ namespace FileManager
|
||||
Replacement.OtherQuote("'"),
|
||||
Replacement.OpenAngleBracket("{"),
|
||||
Replacement.CloseAngleBracket("}"),
|
||||
Replacement.Colon("-"),
|
||||
}
|
||||
}
|
||||
: new ()
|
||||
{
|
||||
Replacements = new Replacement[]
|
||||
Replacement.Colon("-")]
|
||||
};
|
||||
|
||||
private static readonly ReplacementCharacters LoFi_Other = new()
|
||||
{
|
||||
Replacements = [
|
||||
Replacement.OtherInvalid("_"),
|
||||
Replacement.FilenameForwardSlash("_"),
|
||||
Replacement.FilenameBackSlash("\\"),
|
||||
Replacement.OpenQuote("\""),
|
||||
Replacement.CloseQuote("\""),
|
||||
Replacement.OtherQuote("\"")
|
||||
}
|
||||
Replacement.OtherQuote("\"")]
|
||||
};
|
||||
|
||||
public static readonly ReplacementCharacters Barebones
|
||||
= IsWindows
|
||||
? new ()
|
||||
{
|
||||
Replacements = new Replacement[]
|
||||
private static readonly ReplacementCharacters BareBones_NTFS = new()
|
||||
{
|
||||
Replacements = [
|
||||
Replacement.OtherInvalid("_"),
|
||||
Replacement.FilenameForwardSlash("_"),
|
||||
Replacement.FilenameBackSlash("_"),
|
||||
Replacement.OpenQuote("_"),
|
||||
Replacement.CloseQuote("_"),
|
||||
Replacement.OtherQuote("_")
|
||||
}
|
||||
}
|
||||
: new ()
|
||||
{
|
||||
Replacements = new Replacement[]
|
||||
Replacement.OtherQuote("_")]
|
||||
};
|
||||
|
||||
private static readonly ReplacementCharacters BareBones_Other = new()
|
||||
{
|
||||
Replacements = [
|
||||
Replacement.OtherInvalid("_"),
|
||||
Replacement.FilenameForwardSlash("_"),
|
||||
Replacement.FilenameBackSlash("\\"),
|
||||
Replacement.OpenQuote("\""),
|
||||
Replacement.CloseQuote("\""),
|
||||
Replacement.OtherQuote("\"")
|
||||
}
|
||||
Replacement.OtherQuote("\"")]
|
||||
};
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Characters to consider invalid in filenames in addition to those returned by <see cref="Path.GetInvalidFileNameChars()"/>
|
||||
/// </summary>
|
||||
public static char[] AdditionalInvalidFilenameCharacters { get; set; } = [];
|
||||
|
||||
private static bool IsWindows => Environment.OSVersion.Platform is PlatformID.Win32NT;
|
||||
internal static bool IsWindows => Environment.OSVersion.Platform is PlatformID.Win32NT;
|
||||
|
||||
private static readonly char[] invalidPathChars = Path.GetInvalidFileNameChars().Except(new[] {
|
||||
private static char[] invalidPathChars { get; } = Path.GetInvalidFileNameChars().Except(new[] {
|
||||
Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar
|
||||
}).ToArray();
|
||||
|
||||
private static readonly char[] invalidSlashes = Path.GetInvalidFileNameChars().Intersect(new[] {
|
||||
private static char[] invalidSlashes { get; } = Path.GetInvalidFileNameChars().Intersect(new[] {
|
||||
Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar
|
||||
}).ToArray();
|
||||
|
||||
@ -229,8 +224,11 @@ namespace FileManager
|
||||
return DefaultReplacement;
|
||||
}
|
||||
|
||||
private static bool CharIsPathInvalid(char c)
|
||||
=> invalidPathChars.Contains(c) || AdditionalInvalidFilenameCharacters.Contains(c);
|
||||
|
||||
public static bool ContainsInvalidPathChar(string path)
|
||||
=> path.Any(c => invalidPathChars.Contains(c));
|
||||
=> path.Any(CharIsPathInvalid);
|
||||
public static bool ContainsInvalidFilenameChar(string path)
|
||||
=> ContainsInvalidPathChar(path) || path.Any(c => invalidSlashes.Contains(c));
|
||||
|
||||
@ -242,7 +240,7 @@ namespace FileManager
|
||||
{
|
||||
var c = fileName[i];
|
||||
|
||||
if (invalidPathChars.Contains(c)
|
||||
if (CharIsPathInvalid(c)
|
||||
|| invalidSlashes.Contains(c)
|
||||
|| Replacements.Any(r => r.CharacterToReplace == c) /* Replace any other legal characters that they user wants. */ )
|
||||
{
|
||||
@ -267,7 +265,7 @@ namespace FileManager
|
||||
|
||||
if (
|
||||
(
|
||||
invalidPathChars.Contains(c)
|
||||
CharIsPathInvalid(c)
|
||||
|| ( // Replace any other legal characters that they user wants.
|
||||
c != Path.DirectorySeparatorChar
|
||||
&& c != Path.AltDirectorySeparatorChar
|
||||
@ -301,23 +299,21 @@ namespace FileManager
|
||||
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
|
||||
{
|
||||
var defaults = ReplacementCharacters.Default(ReplacementCharacters.IsWindows).Replacements;
|
||||
|
||||
var jObj = JObject.Load(reader);
|
||||
var replaceArr = jObj[nameof(Replacement)];
|
||||
var dict
|
||||
= replaceArr?.ToObject<Replacement[]>()?.ToList()
|
||||
?? ReplacementCharacters.Default.Replacements;
|
||||
|
||||
var dict = replaceArr?.ToObject<Replacement[]>()?.ToList() ?? defaults;
|
||||
|
||||
//Ensure that the first 6 replacements are for the expected chars and that all replacement strings are valid.
|
||||
//If not, reset to default.
|
||||
|
||||
for (int i = 0; i < Replacement.FIXED_COUNT; i++)
|
||||
{
|
||||
if (dict.Count < Replacement.FIXED_COUNT
|
||||
|| dict[i].CharacterToReplace != ReplacementCharacters.Barebones.Replacements[i].CharacterToReplace
|
||||
|| dict[i].Description != ReplacementCharacters.Barebones.Replacements[i].Description)
|
||||
|| dict[i].CharacterToReplace != defaults[i].CharacterToReplace
|
||||
|| dict[i].Description != defaults[i].Description)
|
||||
{
|
||||
dict = ReplacementCharacters.Default.Replacements;
|
||||
dict = defaults;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -71,12 +71,12 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
<PackageReference Include="Avalonia" Version="11.3.2" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.2" />
|
||||
<PackageReference Include="Avalonia" Version="11.3.3" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.3" />
|
||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.2" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.3.2" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.2" />
|
||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.3.3" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.3.3" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.3" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\HangoverBase\HangoverBase.csproj" />
|
||||
|
||||
@ -102,6 +102,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libation UI", "Libation UI"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libation CLI", "Libation CLI", "{47E27674-595D-4F7A-8CFB-127E768E1D1E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssertionHelper", "_Tests\AssertionHelper\AssertionHelper.csproj", "{CFE7A0E5-37FE-40BE-A70B-41B5104181C4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -220,6 +222,10 @@ Global
|
||||
{E90C4651-AF11-41B4-A839-10082D0391F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E90C4651-AF11-41B4-A839-10082D0391F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E90C4651-AF11-41B4-A839-10082D0391F9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CFE7A0E5-37FE-40BE-A70B-41B5104181C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CFE7A0E5-37FE-40BE-A70B-41B5104181C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CFE7A0E5-37FE-40BE-A70B-41B5104181C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CFE7A0E5-37FE-40BE-A70B-41B5104181C4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -258,6 +264,7 @@ Global
|
||||
{FDDABAFE-35AD-42FC-AC95-0B1FE0DF0DDE} = {8679CAC8-9164-4007-BDD2-F004810EDA14}
|
||||
{53758A35-1C7E-4702-9B96-433ABA457B37} = {8679CAC8-9164-4007-BDD2-F004810EDA14}
|
||||
{47E27674-595D-4F7A-8CFB-127E768E1D1E} = {8679CAC8-9164-4007-BDD2-F004810EDA14}
|
||||
{CFE7A0E5-37FE-40BE-A70B-41B5104181C4} = {67E66E82-5532-4440-AFB3-9FB1DF9DEF53}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {615E00ED-BAEF-4E8E-A92A-9B82D87942A9}
|
||||
|
||||
@ -120,7 +120,10 @@ namespace LibationAvalonia
|
||||
ShowMainWindow(desktop);
|
||||
}
|
||||
else
|
||||
await CancelInstallation();
|
||||
{
|
||||
e.Cancel = true;
|
||||
await CancelInstallation(setupDialog);
|
||||
}
|
||||
}
|
||||
else if (setupDialog.IsReturningUser)
|
||||
{
|
||||
@ -128,7 +131,8 @@ namespace LibationAvalonia
|
||||
}
|
||||
else
|
||||
{
|
||||
await CancelInstallation();
|
||||
e.Cancel = true;
|
||||
await CancelInstallation(setupDialog);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -139,11 +143,11 @@ namespace LibationAvalonia
|
||||
var body = "An unrecoverable error occurred. Since this error happened before logging could be initialized, this error can not be written to the log file.";
|
||||
try
|
||||
{
|
||||
await MessageBox.ShowAdminAlert(null, body, title, ex);
|
||||
await MessageBox.ShowAdminAlert(setupDialog, body, title, ex);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await MessageBox.Show($"{body}\r\n\r\n{ex.Message}\r\n\r\n{ex.StackTrace}", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
await MessageBox.Show(setupDialog, $"{body}\r\n\r\n{ex.Message}\r\n\r\n{ex.StackTrace}", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -190,6 +194,7 @@ namespace LibationAvalonia
|
||||
{
|
||||
// path did not result in valid settings
|
||||
var continueResult = await MessageBox.Show(
|
||||
libationFilesDialog,
|
||||
$"No valid settings were found at this location.\r\nWould you like to create a new install settings in this folder?\r\n\r\n{libationFilesDialog.SelectedDirectory}",
|
||||
"New install?",
|
||||
MessageBoxButtons.YesNo,
|
||||
@ -207,18 +212,18 @@ namespace LibationAvalonia
|
||||
ShowMainWindow(desktop);
|
||||
}
|
||||
else
|
||||
await CancelInstallation();
|
||||
await CancelInstallation(libationFilesDialog);
|
||||
}
|
||||
else
|
||||
await CancelInstallation();
|
||||
await CancelInstallation(libationFilesDialog);
|
||||
}
|
||||
|
||||
libationFilesDialog.Close();
|
||||
}
|
||||
|
||||
static async Task CancelInstallation()
|
||||
static async Task CancelInstallation(Window window)
|
||||
{
|
||||
await MessageBox.Show("Initial set up cancelled.", "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
await MessageBox.Show(window, "Initial set up cancelled.", "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
|
||||
|
||||
@ -92,16 +92,14 @@ namespace LibationAvalonia.Controls
|
||||
base.UpdateDataValidation(property, state, error);
|
||||
if (property == CommandProperty)
|
||||
{
|
||||
if (state == BindingValueType.BindingError)
|
||||
var canExecure = !state.HasFlag(BindingValueType.HasError);
|
||||
if (canExecure != _commandCanExecute)
|
||||
{
|
||||
if (_commandCanExecute)
|
||||
{
|
||||
_commandCanExecute = false;
|
||||
_commandCanExecute = canExecure;
|
||||
UpdateIsEffectivelyEnabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CanExecuteChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@ -47,27 +47,33 @@
|
||||
SelectedItem="{CompiledBinding FileDownloadQuality}"/>
|
||||
</Grid>
|
||||
|
||||
|
||||
<Grid ColumnDefinitions="*,*">
|
||||
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<CheckBox
|
||||
IsChecked="{CompiledBinding UseWidevine, Mode=TwoWay}"
|
||||
ToolTip.Tip="{CompiledBinding UseWidevineTip}"
|
||||
IsCheckedChanged="UseWidevine_IsCheckedChanged"
|
||||
ToolTip.Tip="{CompiledBinding UseWidevineTip}">
|
||||
IsChecked="{CompiledBinding UseWidevine, Mode=TwoWay}">
|
||||
<TextBlock Text="{CompiledBinding UseWidevineText}" />
|
||||
</CheckBox>
|
||||
|
||||
<CheckBox
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Right"
|
||||
ToolTip.Tip="{CompiledBinding Request_xHE_AACTip}"
|
||||
IsEnabled="{CompiledBinding UseWidevine}"
|
||||
IsChecked="{CompiledBinding Request_xHE_AAC, Mode=TwoWay}">
|
||||
<TextBlock Text="{CompiledBinding Request_xHE_AACText}" />
|
||||
</CheckBox>
|
||||
</Grid>
|
||||
|
||||
<Grid ColumnDefinitions="*,Auto">
|
||||
<CheckBox
|
||||
ToolTip.Tip="{CompiledBinding RequestSpatialTip}"
|
||||
IsEnabled="{CompiledBinding UseWidevine}"
|
||||
IsChecked="{CompiledBinding RequestSpatial, Mode=TwoWay}">
|
||||
<TextBlock Text="{CompiledBinding RequestSpatialText}" />
|
||||
</CheckBox>
|
||||
</Grid>
|
||||
|
||||
<Grid ColumnDefinitions="*,Auto"
|
||||
<Grid
|
||||
Grid.Column="1"
|
||||
ColumnDefinitions="Auto,Auto"
|
||||
VerticalAlignment="Top"
|
||||
ToolTip.Tip="{CompiledBinding SpatialAudioCodecTip}">
|
||||
<Grid.IsEnabled>
|
||||
<MultiBinding Converter="{x:Static BoolConverters.And}">
|
||||
@ -80,19 +86,18 @@
|
||||
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
Text="{CompiledBinding SpatialAudioCodecText}" />
|
||||
Text="Codec:"/>
|
||||
|
||||
<controls:WheelComboBox
|
||||
Margin="5,0,0,0"
|
||||
Grid.Column="1"
|
||||
VerticalAlignment="Center"
|
||||
SelectionChanged="SpatialCodec_SelectionChanged"
|
||||
ItemsSource="{CompiledBinding SpatialAudioCodecs}"
|
||||
SelectedItem="{CompiledBinding SpatialAudioCodec}"/>
|
||||
</Grid>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
<CheckBox IsChecked="{CompiledBinding CreateCueSheet, Mode=TwoWay}">
|
||||
<TextBlock Text="{CompiledBinding CreateCueSheetText}" />
|
||||
|
||||
@ -5,6 +5,7 @@ using LibationAvalonia.ViewModels.Settings;
|
||||
using LibationFileManager;
|
||||
using LibationFileManager.Templates;
|
||||
using LibationUiBase.Forms;
|
||||
using ReactiveUI;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -23,6 +24,15 @@ namespace LibationAvalonia.Controls.Settings
|
||||
}
|
||||
}
|
||||
|
||||
private void SpatialCodec_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (_viewModel.SpatialAudioCodec.Value is Configuration.SpatialCodec.AC_4 && _viewModel.DecryptToLossy)
|
||||
{
|
||||
_viewModel.SpatialAudioCodec = _viewModel.SpatialAudioCodecs[0];
|
||||
_viewModel.RaisePropertyChanged(nameof(AudioSettingsVM.SpatialAudioCodec));
|
||||
}
|
||||
}
|
||||
|
||||
private async void UseWidevine_IsCheckedChanged(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
if (sender is CheckBox cbox && cbox.IsChecked is true)
|
||||
@ -59,6 +69,10 @@ namespace LibationAvalonia.Controls.Settings
|
||||
_viewModel.UseWidevine = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_viewModel.Request_xHE_AAC = _viewModel.RequestSpatial = false;
|
||||
}
|
||||
}
|
||||
|
||||
public async void EditChapterTitleTemplateButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
|
||||
@ -61,7 +61,7 @@ namespace LibationAvalonia.Dialogs
|
||||
private void Link_getlibation(object sender, Avalonia.Input.TappedEventArgs e) => Dinah.Core.Go.To.Url(AppScaffolding.LibationScaffolding.WebsiteUrl);
|
||||
|
||||
private void ViewReleaseNotes_Tapped(object sender, Avalonia.Input.TappedEventArgs e)
|
||||
=> Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{AppScaffolding.LibationScaffolding.BuildVersion.ToString(3)}");
|
||||
=> Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{AppScaffolding.LibationScaffolding.BuildVersion.ToVersionString()}");
|
||||
}
|
||||
|
||||
public class AboutVM : ViewModelBase
|
||||
|
||||
@ -6,6 +6,8 @@
|
||||
MinWidth="500" MinHeight="450"
|
||||
Width="500" Height="450"
|
||||
x:Class="LibationAvalonia.Dialogs.EditReplacementChars"
|
||||
xmlns:dialogs="clr-namespace:LibationAvalonia.Dialogs"
|
||||
x:DataType="dialogs:EditReplacementChars"
|
||||
Title="Illegal Character Replacement">
|
||||
|
||||
<Grid
|
||||
@ -23,31 +25,30 @@
|
||||
BeginningEdit="ReplacementGrid_BeginningEdit"
|
||||
CellEditEnding="ReplacementGrid_CellEditEnding"
|
||||
KeyDown="ReplacementGrid_KeyDown"
|
||||
ItemsSource="{Binding replacements}">
|
||||
ItemsSource="{CompiledBinding replacements}">
|
||||
|
||||
<DataGrid.Columns>
|
||||
|
||||
|
||||
<DataGridTemplateColumn Header="Char to
Replace">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBox IsReadOnly="{Binding Mandatory}" Text="{Binding CharacterToReplace, Mode=TwoWay}" />
|
||||
<DataTemplate x:DataType="dialogs:EditReplacementChars+ReplacementsExt">
|
||||
<TextBox IsReadOnly="{CompiledBinding Mandatory}" Text="{CompiledBinding CharacterToReplace, Mode=TwoWay}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Header="Replacement
Text">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBox Text="{Binding ReplacementText, Mode=TwoWay}" />
|
||||
<DataTemplate x:DataType="dialogs:EditReplacementChars+ReplacementsExt">
|
||||
<TextBox Text="{CompiledBinding ReplacementText, Mode=TwoWay}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
<DataGridTemplateColumn Width="*" Header="Description">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBox IsReadOnly="{Binding Mandatory}" Text="{Binding Description, Mode=TwoWay}" />
|
||||
<DataTemplate x:DataType="dialogs:EditReplacementChars+ReplacementsExt">
|
||||
<TextBox IsReadOnly="{CompiledBinding Mandatory}" Text="{CompiledBinding Description, Mode=TwoWay}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
@ -55,21 +56,31 @@
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
<StackPanel
|
||||
<Grid
|
||||
Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
RowDefinitions="Auto,Auto"
|
||||
Margin="5"
|
||||
Orientation="Horizontal">
|
||||
ColumnDefinitions="Auto,Auto,Auto,Auto">
|
||||
|
||||
<Button Margin="0,0,10,0" Command="{Binding Defaults}" Content="Defaults" />
|
||||
<Button Margin="0,0,10,0" Command="{Binding LoFiDefaults}" Content="LoFi Defaults" />
|
||||
<Button Command="{Binding Barebones}" Content="Barebones" />
|
||||
</StackPanel>
|
||||
<TextBlock IsVisible="{CompiledBinding !EnvironmentIsWindows}" Text="This System:" Margin="0,0,10,0" VerticalAlignment="Center" />
|
||||
<TextBlock IsVisible="{CompiledBinding !EnvironmentIsWindows}" Grid.Row="1" Text="NTFS:" Margin="0,0,10,0" VerticalAlignment="Center" />
|
||||
|
||||
<Button Grid.Column="1" Margin="0,0,10,0" Command="{CompiledBinding Defaults}" CommandParameter="{CompiledBinding EnvironmentIsWindows}" Content="Defaults" />
|
||||
<Button Grid.Column="2" Margin="0,0,10,0" Command="{CompiledBinding LoFiDefaults}" CommandParameter="{CompiledBinding EnvironmentIsWindows}" Content="LoFi Defaults" />
|
||||
<Button Grid.Column="3" Command="{CompiledBinding Barebones}" CommandParameter="{CompiledBinding EnvironmentIsWindows}" Content="Barebones" />
|
||||
|
||||
<Button IsVisible="{CompiledBinding !EnvironmentIsWindows}" Grid.Row="1" Grid.Column="1" Margin="0,10,10,0" Command="{CompiledBinding Defaults}" CommandParameter="True" Content="Defaults" />
|
||||
<Button IsVisible="{CompiledBinding !EnvironmentIsWindows}" Grid.Row="1" Grid.Column="2" Margin="0,10,10,0" Command="{CompiledBinding LoFiDefaults}" CommandParameter="True" Content="LoFi Defaults" />
|
||||
<Button IsVisible="{CompiledBinding !EnvironmentIsWindows}" Grid.Row="1" Grid.Column="3" Margin="0,10,0,0" Command="{CompiledBinding Barebones}" CommandParameter="True" Content="Barebones" />
|
||||
|
||||
</Grid>
|
||||
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Margin="5"
|
||||
VerticalAlignment="Bottom"
|
||||
Orientation="Horizontal">
|
||||
|
||||
<Button Margin="0,0,10,0" Command="{Binding Close}" Content="Cancel" />
|
||||
|
||||
@ -13,6 +13,8 @@ namespace LibationAvalonia.Dialogs
|
||||
{
|
||||
Configuration config;
|
||||
|
||||
public bool EnvironmentIsWindows => Configuration.IsWindows;
|
||||
|
||||
private readonly List<ReplacementsExt> SOURCE = new();
|
||||
public DataGridCollectionView replacements { get; }
|
||||
public EditReplacementChars()
|
||||
@ -23,7 +25,7 @@ namespace LibationAvalonia.Dialogs
|
||||
|
||||
if (Design.IsDesignMode)
|
||||
{
|
||||
LoadTable(ReplacementCharacters.Default.Replacements);
|
||||
LoadTable(ReplacementCharacters.Default(true).Replacements);
|
||||
}
|
||||
|
||||
DataContext = this;
|
||||
@ -35,12 +37,12 @@ namespace LibationAvalonia.Dialogs
|
||||
LoadTable(config.ReplacementCharacters.Replacements);
|
||||
}
|
||||
|
||||
public void Defaults()
|
||||
=> LoadTable(ReplacementCharacters.Default.Replacements);
|
||||
public void LoFiDefaults()
|
||||
=> LoadTable(ReplacementCharacters.LoFiDefault.Replacements);
|
||||
public void Barebones()
|
||||
=> LoadTable(ReplacementCharacters.Barebones.Replacements);
|
||||
public void Defaults(bool isNtfs)
|
||||
=> LoadTable(ReplacementCharacters.Default(isNtfs).Replacements);
|
||||
public void LoFiDefaults(bool isNtfs)
|
||||
=> LoadTable(ReplacementCharacters.LoFiDefault(isNtfs).Replacements);
|
||||
public void Barebones(bool isNtfs)
|
||||
=> LoadTable(ReplacementCharacters.Barebones(isNtfs).Replacements);
|
||||
|
||||
protected override void SaveAndClose()
|
||||
{
|
||||
|
||||
@ -6,24 +6,28 @@
|
||||
Width="800" Height="450"
|
||||
x:Class="LibationAvalonia.Dialogs.EditTemplateDialog"
|
||||
xmlns:dialogs="clr-namespace:LibationAvalonia.Dialogs"
|
||||
xmlns:controls="clr-namespace:LibationAvalonia.Controls"
|
||||
x:DataType="dialogs:EditTemplateDialog+EditTemplateViewModel"
|
||||
Title="EditTemplateDialog">
|
||||
|
||||
<Grid RowDefinitions="Auto,*,Auto">
|
||||
<Grid RowDefinitions="Auto,*,Auto" Margin="10">
|
||||
<Grid
|
||||
Grid.Row="0"
|
||||
RowDefinitions="Auto,Auto"
|
||||
ColumnDefinitions="*,Auto" Margin="5">
|
||||
ColumnDefinitions="*,Auto"
|
||||
Margin="0,0,0,10">
|
||||
|
||||
<TextBlock
|
||||
Grid.Column="0"
|
||||
Grid.Row="0"
|
||||
Text="{Binding Description}" />
|
||||
Margin="0,0,0,10"
|
||||
Text="{CompiledBinding Description}" />
|
||||
|
||||
<TextBox
|
||||
Grid.Column="0"
|
||||
Grid.Row="1"
|
||||
Name="userEditTbox"
|
||||
Text="{Binding UserTemplateText, Mode=TwoWay}" />
|
||||
Text="{CompiledBinding UserTemplateText, Mode=TwoWay}" />
|
||||
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
@ -32,9 +36,10 @@
|
||||
VerticalAlignment="Stretch"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="Reset to Default"
|
||||
Command="{Binding ResetToDefault}"/>
|
||||
Command="{CompiledBinding ResetToDefault}"/>
|
||||
</Grid>
|
||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,*">
|
||||
<Grid Grid.Row="1" ColumnDefinitions="Auto,*"
|
||||
Margin="0,0,0,10">
|
||||
|
||||
<DataGrid
|
||||
Grid.Row="0"
|
||||
@ -44,13 +49,13 @@
|
||||
GridLinesVisibility="All"
|
||||
AutoGenerateColumns="False"
|
||||
DoubleTapped="EditTemplateViewModel_DoubleTapped"
|
||||
ItemsSource="{Binding ListItems}" >
|
||||
ItemsSource="{CompiledBinding ListItems}" >
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Width="Auto" Header="Tag">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Height="18" Margin="10,0,10,0" VerticalAlignment="Center" Text="{Binding Item1}" />
|
||||
<TextBlock Height="18" Margin="10,0,10,0" VerticalAlignment="Center" Text="{CompiledBinding Item1}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
@ -61,7 +66,7 @@
|
||||
<TextBlock
|
||||
Height="18"
|
||||
Margin="10,0,10,0"
|
||||
VerticalAlignment="Center" Text="{Binding Item2}" />
|
||||
VerticalAlignment="Center" Text="{CompiledBinding Item2}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
@ -71,23 +76,22 @@
|
||||
|
||||
<Grid
|
||||
Grid.Column="1"
|
||||
Margin="5,0,5,0"
|
||||
Margin="10,0,0,0"
|
||||
RowDefinitions="Auto,*,Auto"
|
||||
HorizontalAlignment="Stretch">
|
||||
|
||||
<TextBlock
|
||||
Margin="5,5,5,10"
|
||||
Margin="0,0,0,5"
|
||||
Text="Example:"/>
|
||||
|
||||
<Border
|
||||
Grid.Row="1"
|
||||
Margin="5"
|
||||
BorderThickness="1"
|
||||
BorderBrush="{DynamicResource DataGridGridLinesBrush}">
|
||||
|
||||
<TextBlock
|
||||
TextWrapping="WrapWithOverflow"
|
||||
Inlines="{Binding Inlines}" />
|
||||
Inlines="{CompiledBinding Inlines}" />
|
||||
|
||||
</Border>
|
||||
|
||||
@ -95,13 +99,17 @@
|
||||
Grid.Row="2"
|
||||
Margin="5"
|
||||
Foreground="Firebrick"
|
||||
Text="{Binding WarningText}"
|
||||
IsVisible="{Binding WarningText, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
|
||||
Text="{CompiledBinding WarningText}"
|
||||
IsVisible="{CompiledBinding WarningText, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<controls:LinkLabel
|
||||
Grid.Row="2"
|
||||
VerticalAlignment="Center"
|
||||
Text="Read about naming templates on the Wiki"
|
||||
Command="{Binding GoToNamingTemplateWiki}" />
|
||||
<Button
|
||||
Grid.Row="2"
|
||||
Margin="5"
|
||||
Padding="30,5,30,5"
|
||||
HorizontalAlignment="Right"
|
||||
Content="Save"
|
||||
|
||||
@ -70,7 +70,7 @@ public partial class EditTemplateDialog : DialogWindow
|
||||
public async void SaveButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
=> await SaveAndCloseAsync();
|
||||
|
||||
private class EditTemplateViewModel : ViewModels.ViewModelBase
|
||||
internal class EditTemplateViewModel : ViewModels.ViewModelBase
|
||||
{
|
||||
private readonly Configuration config;
|
||||
public InlineCollection Inlines { get; } = new();
|
||||
@ -96,6 +96,9 @@ public partial class EditTemplateDialog : DialogWindow
|
||||
|
||||
}
|
||||
|
||||
public void GoToNamingTemplateWiki()
|
||||
=> Go.To.Url(@"ht" + "tps://github.com/rmcrackan/Libation/blob/master/Documentation/NamingTemplates.md");
|
||||
|
||||
// hold the work-in-progress value. not guaranteed to be valid
|
||||
private string _userTemplateText;
|
||||
public string UserTemplateText
|
||||
|
||||
@ -13,11 +13,12 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#nullable enable
|
||||
namespace LibationAvalonia.Dialogs
|
||||
{
|
||||
public partial class LocateAudiobooksDialog : DialogWindow
|
||||
{
|
||||
private event EventHandler<FilePathCache.CacheEntry> FileFound;
|
||||
private event EventHandler<FilePathCache.CacheEntry>? FileFound;
|
||||
private readonly CancellationTokenSource tokenSource = new();
|
||||
private readonly List<string> foundAsins = new();
|
||||
private readonly LocatedAudiobooksViewModel _viewModel;
|
||||
@ -41,7 +42,7 @@ namespace LibationAvalonia.Dialogs
|
||||
}
|
||||
}
|
||||
|
||||
private void LocateAudiobooksDialog_Closing(object sender, System.ComponentModel.CancelEventArgs e)
|
||||
private void LocateAudiobooksDialog_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
tokenSource.Cancel();
|
||||
//If this dialog is closed before it's completed, Closing is fired
|
||||
@ -50,7 +51,7 @@ namespace LibationAvalonia.Dialogs
|
||||
this.SaveSizeAndLocation(Configuration.Instance);
|
||||
}
|
||||
|
||||
private void LocateAudiobooks_FileFound(object sender, FilePathCache.CacheEntry e)
|
||||
private void LocateAudiobooks_FileFound(object? sender, FilePathCache.CacheEntry e)
|
||||
{
|
||||
var newItem = new Tuple<string, string>($"[{e.Id}]", Path.GetFileName(e.Path));
|
||||
_viewModel.FoundFiles.Add(newItem);
|
||||
@ -63,13 +64,13 @@ namespace LibationAvalonia.Dialogs
|
||||
}
|
||||
}
|
||||
|
||||
private async void LocateAudiobooksDialog_Opened(object sender, EventArgs e)
|
||||
private async void LocateAudiobooksDialog_Opened(object? sender, EventArgs e)
|
||||
{
|
||||
var folderPicker = new FolderPickerOpenOptions
|
||||
{
|
||||
Title = "Select the folder to search for audiobooks",
|
||||
AllowMultiple = false,
|
||||
SuggestedStartLocation = await StorageProvider.TryGetFolderFromPathAsync(Configuration.Instance.Books.PathWithoutPrefix)
|
||||
SuggestedStartLocation = await StorageProvider.TryGetFolderFromPathAsync(Configuration.Instance.Books?.PathWithoutPrefix ?? "")
|
||||
};
|
||||
|
||||
var selectedFolder = (await StorageProvider.OpenFolderPickerAsync(folderPicker))?.SingleOrDefault()?.TryGetLocalPath();
|
||||
@ -89,11 +90,13 @@ namespace LibationAvalonia.Dialogs
|
||||
FilePathCache.Insert(book);
|
||||
|
||||
var lb = context.GetLibraryBook_Flat_NoTracking(book.Id);
|
||||
if (lb?.Book?.UserDefinedItem.BookStatus is not LiberatedStatus.Liberated)
|
||||
if (lb is not null && lb.Book?.UserDefinedItem.BookStatus is not LiberatedStatus.Liberated)
|
||||
await Task.Run(() => lb.UpdateBookStatus(LiberatedStatus.Liberated));
|
||||
|
||||
tokenSource.Token.ThrowIfCancellationRequested();
|
||||
FileFound?.Invoke(this, book);
|
||||
}
|
||||
catch (OperationCanceledException) { }
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Error(ex, "Error adding found audiobook file to Libation. {@audioFile}", book);
|
||||
|
||||
@ -48,13 +48,13 @@
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1" RowDefinitions="Auto,Auto,*">
|
||||
<TextBlock Text="NUMBER FIELDS" />
|
||||
<TextBlock Text="STRING FIELDS" />
|
||||
<TextBlock Grid.Row="1" Text="{CompiledBinding StringUsage}" />
|
||||
<ListBox Grid.Row="2" ItemsSource="{CompiledBinding StringFields}"/>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1" Grid.Column="1" RowDefinitions="Auto,Auto,*">
|
||||
<TextBlock Text="STRING FIELDS" />
|
||||
<TextBlock Text="NUMBER FIELDS" />
|
||||
<TextBlock Grid.Row="1" Text="{CompiledBinding NumberUsage}" />
|
||||
<ListBox Grid.Row="2" ItemsSource="{CompiledBinding NumberFields}"/>
|
||||
</Grid>
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
using Avalonia.Controls;
|
||||
using FileManager;
|
||||
using LibationAvalonia.ViewModels.Settings;
|
||||
using LibationFileManager;
|
||||
using LibationUiBase.Forms;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibationAvalonia.Dialogs
|
||||
@ -39,6 +41,21 @@ namespace LibationAvalonia.Dialogs
|
||||
}
|
||||
|
||||
public async void SaveButton_Clicked(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
=> await SaveAndCloseAsync();
|
||||
{
|
||||
LongPath lonNewBooks = settingsDisp.ImportantSettings.GetBooksDirectory();
|
||||
if (!System.IO.Directory.Exists(lonNewBooks))
|
||||
{
|
||||
try
|
||||
{
|
||||
System.IO.Directory.CreateDirectory(lonNewBooks);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await MessageBox.Show(this, $"Error creating Books Location:\n\n{ex.Message}", "Error creating directory", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
await SaveAndCloseAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using AppScaffolding;
|
||||
using Avalonia.Controls;
|
||||
using Dinah.Core;
|
||||
using LibationFileManager;
|
||||
using LibationUiBase.Forms;
|
||||
|
||||
namespace LibationAvalonia.Dialogs
|
||||
@ -30,7 +31,7 @@ namespace LibationAvalonia.Dialogs
|
||||
|
||||
public UpgradeNotificationDialog(UpgradeProperties upgradeProperties, bool canUpgrade) : this()
|
||||
{
|
||||
Title = $"Libation version {upgradeProperties.LatestRelease.ToString(3)} is now available.";
|
||||
Title = $"Libation version {upgradeProperties.LatestRelease.ToVersionString()} is now available.";
|
||||
PackageUrl = upgradeProperties.ZipUrl;
|
||||
DownloadLinkText = upgradeProperties.ZipName;
|
||||
ReleaseNotes = upgradeProperties.Notes;
|
||||
|
||||
@ -73,13 +73,13 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="11.3.2" />
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.2" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
|
||||
<PackageReference Include="Avalonia" Version="11.3.2" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.2" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.2" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.3.2" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.2" />
|
||||
<PackageReference Include="Avalonia.Controls.ColorPicker" Version="11.3.3" />
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.3" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" />
|
||||
<PackageReference Include="Avalonia" Version="11.3.3" />
|
||||
<PackageReference Include="Avalonia.Controls.DataGrid" Version="11.3.3" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.3" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.3.3" />
|
||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -20,6 +20,7 @@ namespace LibationAvalonia.ViewModels
|
||||
private bool _removeButtonsVisible = Design.IsDesignMode;
|
||||
private int _numAccountsScanning = 2;
|
||||
private int _accountsCount = 0;
|
||||
public string LocateAudiobooksTip => Configuration.GetHelpText("LocateAudiobooks");
|
||||
|
||||
/// <summary> Auto scanning accounts is enables </summary>
|
||||
public bool AutoScanChecked { get => _autoScanChecked; set => Configuration.Instance.AutoScan = this.RaiseAndSetIfChanged(ref _autoScanChecked, value); }
|
||||
@ -68,7 +69,8 @@ namespace LibationAvalonia.ViewModels
|
||||
MainWindow.Loaded += (_, _) =>
|
||||
{
|
||||
refreshImportMenu();
|
||||
AccountsSettingsPersister.Saved += refreshImportMenu;
|
||||
AccountsSettingsPersister.Saved += (_, _)
|
||||
=> Avalonia.Threading.Dispatcher.UIThread.Invoke(refreshImportMenu);
|
||||
};
|
||||
|
||||
AutoScanChecked = Configuration.Instance.AutoScan;
|
||||
@ -171,10 +173,21 @@ namespace LibationAvalonia.ViewModels
|
||||
}
|
||||
|
||||
public async Task LocateAudiobooksAsync()
|
||||
{
|
||||
var result = await MessageBox.Show(
|
||||
MainWindow,
|
||||
Configuration.GetHelpText(nameof(LibationAvalonia.Dialogs.LocateAudiobooksDialog)),
|
||||
"Locate Previously-Liberated Audiobook Files",
|
||||
MessageBoxButtons.OKCancel,
|
||||
MessageBoxIcon.Information,
|
||||
MessageBoxDefaultButton.Button1);
|
||||
|
||||
if (result is DialogResult.OK)
|
||||
{
|
||||
var locateDialog = new LibationAvalonia.Dialogs.LocateAudiobooksDialog();
|
||||
await locateDialog.ShowDialog(MainWindow);
|
||||
}
|
||||
}
|
||||
|
||||
private void setyNumScanningAccounts(int numScanning)
|
||||
{
|
||||
@ -222,7 +235,7 @@ namespace LibationAvalonia.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshImportMenu(object? _ = null, EventArgs? __ = null)
|
||||
private void refreshImportMenu()
|
||||
{
|
||||
using var persister = AudibleApiStorage.GetAccountsSettingsPersister();
|
||||
AccountsCount = persister.AccountsSettings.Accounts.Count;
|
||||
|
||||
@ -54,7 +54,6 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
StripAudibleBrandAudio = config.StripAudibleBrandAudio;
|
||||
StripUnabridged = config.StripUnabridged;
|
||||
_chapterTitleTemplate = config.ChapterTitleTemplate;
|
||||
DecryptToLossy = config.DecryptToLossy;
|
||||
MoveMoovToBeginning = config.MoveMoovToBeginning;
|
||||
LameTargetBitrate = config.LameTargetBitrate;
|
||||
LameDownsampleMono = config.LameDownsampleMono;
|
||||
@ -69,6 +68,8 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
SelectedEncoderQuality = config.LameEncoderQuality;
|
||||
UseWidevine = config.UseWidevine;
|
||||
RequestSpatial = config.RequestSpatial;
|
||||
Request_xHE_AAC = config.Request_xHE_AAC;
|
||||
DecryptToLossy = config.DecryptToLossy;
|
||||
}
|
||||
|
||||
public void SaveSettings(Configuration config)
|
||||
@ -100,6 +101,7 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
config.SpatialAudioCodec = SpatialAudioCodec?.Value ?? config.SpatialAudioCodec;
|
||||
config.UseWidevine = UseWidevine;
|
||||
config.RequestSpatial = RequestSpatial;
|
||||
config.Request_xHE_AAC = Request_xHE_AAC;
|
||||
}
|
||||
|
||||
public AvaloniaList<EnumDisplay<Configuration.DownloadQuality>> DownloadQualities { get; } = new([
|
||||
@ -114,9 +116,10 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
public string FileDownloadQualityText { get; } = Configuration.GetDescription(nameof(Configuration.FileDownloadQuality));
|
||||
public string UseWidevineText { get; } = Configuration.GetDescription(nameof(Configuration.UseWidevine));
|
||||
public string UseWidevineTip { get; } = Configuration.GetHelpText(nameof(Configuration.UseWidevine));
|
||||
public string Request_xHE_AACText { get; } = Configuration.GetDescription(nameof(Configuration.Request_xHE_AAC));
|
||||
public string Request_xHE_AACTip { get; } = Configuration.GetHelpText(nameof(Configuration.Request_xHE_AAC));
|
||||
public string RequestSpatialText { get; } = Configuration.GetDescription(nameof(Configuration.RequestSpatial));
|
||||
public string RequestSpatialTip { get; } = Configuration.GetHelpText(nameof(Configuration.RequestSpatial));
|
||||
public string SpatialAudioCodecText { get; } = Configuration.GetDescription(nameof(Configuration.SpatialAudioCodec));
|
||||
public string SpatialAudioCodecTip { get; } = Configuration.GetHelpText(nameof(Configuration.SpatialAudioCodec));
|
||||
public string CreateCueSheetText { get; } = Configuration.GetDescription(nameof(Configuration.CreateCueSheet));
|
||||
public string CombineNestedChapterTitlesText { get; } = Configuration.GetDescription(nameof(Configuration.CombineNestedChapterTitles));
|
||||
@ -140,10 +143,9 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
public string RetainAaxFileTip => Configuration.GetHelpText(nameof(RetainAaxFile));
|
||||
public bool DownloadClipsBookmarks { get => _downloadClipsBookmarks; set => this.RaiseAndSetIfChanged(ref _downloadClipsBookmarks, value); }
|
||||
|
||||
|
||||
private bool _useWidevine;
|
||||
private bool _requestSpatial;
|
||||
private bool _useWidevine, _requestSpatial, _request_xHE_AAC;
|
||||
public bool UseWidevine { get => _useWidevine; set => this.RaiseAndSetIfChanged(ref _useWidevine, value); }
|
||||
public bool Request_xHE_AAC { get => _request_xHE_AAC; set => this.RaiseAndSetIfChanged(ref _request_xHE_AAC, value); }
|
||||
public bool RequestSpatial { get => _requestSpatial; set => this.RaiseAndSetIfChanged(ref _requestSpatial, value); }
|
||||
|
||||
public EnumDisplay<Configuration.DownloadQuality> FileDownloadQuality { get; set; }
|
||||
@ -155,7 +157,18 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
public string StripAudibleBrandAudioTip => Configuration.GetHelpText(nameof(StripAudibleBrandAudio));
|
||||
public bool StripUnabridged { get; set; }
|
||||
public string StripUnabridgedTip => Configuration.GetHelpText(nameof(StripUnabridged));
|
||||
public bool DecryptToLossy { get => _decryptToLossy; set => this.RaiseAndSetIfChanged(ref _decryptToLossy, value); }
|
||||
public bool DecryptToLossy {
|
||||
get => _decryptToLossy;
|
||||
set
|
||||
{
|
||||
this.RaiseAndSetIfChanged(ref _decryptToLossy, value);
|
||||
if (DecryptToLossy && SpatialAudioCodec.Value is Configuration.SpatialCodec.AC_4)
|
||||
{
|
||||
SpatialAudioCodec = SpatialAudioCodecs[0];
|
||||
this.RaisePropertyChanged(nameof(SpatialAudioCodec));
|
||||
}
|
||||
}
|
||||
}
|
||||
public string DecryptToLossyTip => Configuration.GetHelpText(nameof(DecryptToLossy));
|
||||
public bool MoveMoovToBeginning { get; set; }
|
||||
|
||||
|
||||
@ -36,10 +36,7 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
|
||||
public void SaveSettings(Configuration config)
|
||||
{
|
||||
LongPath lonNewBooks = Configuration.GetKnownDirectory(BooksDirectory) is Configuration.KnownDirectories.None ? BooksDirectory : System.IO.Path.Combine(BooksDirectory, "Books");
|
||||
if (!System.IO.Directory.Exists(lonNewBooks))
|
||||
System.IO.Directory.CreateDirectory(lonNewBooks);
|
||||
config.Books = lonNewBooks;
|
||||
config.Books = GetBooksDirectory();
|
||||
config.SavePodcastsToParentFolder = SavePodcastsToParentFolder;
|
||||
config.OverwriteExisting = OverwriteExisting;
|
||||
config.CreationTime = CreationTime.Value;
|
||||
@ -47,6 +44,9 @@ namespace LibationAvalonia.ViewModels.Settings
|
||||
config.LogLevel = LoggingLevel;
|
||||
}
|
||||
|
||||
public LongPath GetBooksDirectory()
|
||||
=> Configuration.GetKnownDirectory(BooksDirectory) is Configuration.KnownDirectories.None ? BooksDirectory : System.IO.Path.Combine(BooksDirectory, "Books");
|
||||
|
||||
private static float scaleFactorToLinearRange(float scaleFactor)
|
||||
=> float.Round(100 * MathF.Log2(scaleFactor));
|
||||
private static float linearRangeToScaleFactor(float value)
|
||||
|
||||
@ -110,7 +110,7 @@
|
||||
<MenuItem IsVisible="{CompiledBinding MultipleAccounts}" IsEnabled="{CompiledBinding RemoveMenuItemsEnabled}" Command="{CompiledBinding RemoveBooksSomeAsync}" Header="_Remove Books from Some Accounts" />
|
||||
|
||||
<Separator />
|
||||
<MenuItem Command="{CompiledBinding LocateAudiobooksAsync}" Header="L_ocate Audiobooks..." />
|
||||
<MenuItem Command="{CompiledBinding LocateAudiobooksAsync}" Header="L_ocate Audiobooks..." ToolTip.Tip="{CompiledBinding LocateAudiobooksTip}" />
|
||||
|
||||
</MenuItem>
|
||||
|
||||
|
||||
@ -43,6 +43,22 @@ namespace LibationAvalonia.Views
|
||||
KeyBindings.Add(new KeyBinding { Command = ReactiveCommand.Create(ViewModel.ShowAccountsAsync), Gesture = new KeyGesture(Key.A, KeyModifiers.Control | KeyModifiers.Shift) });
|
||||
KeyBindings.Add(new KeyBinding { Command = ReactiveCommand.Create(ViewModel.ExportLibraryAsync), Gesture = new KeyGesture(Key.S, KeyModifiers.Control) });
|
||||
}
|
||||
|
||||
Configuration.Instance.PropertyChanged += Settings_PropertyChanged;
|
||||
Settings_PropertyChanged(this, null);
|
||||
}
|
||||
|
||||
[Dinah.Core.PropertyChangeFilter(nameof(Configuration.Books))]
|
||||
private void Settings_PropertyChanged(object sender, Dinah.Core.PropertyChangedEventArgsEx e)
|
||||
{
|
||||
if (!Configuration.IsWindows)
|
||||
{
|
||||
//The books directory does not support filenames with windows' invalid characters.
|
||||
//Tell the ReplacementCharacters configuration to treat those characters as invalid.
|
||||
ReplacementCharacters.AdditionalInvalidFilenameCharacters
|
||||
= Configuration.Instance.BooksCanWriteWindowsInvalidChars ? []
|
||||
: FileSystemTest.AdditionalInvalidWindowsFilenameCharacters.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
private void AudibleApiStorage_LoadError(object sender, AccountSettingsLoadErrorEventArgs e)
|
||||
@ -54,7 +70,7 @@ namespace LibationAvalonia.Views
|
||||
FileUtility.SaferMoveToValidPath(
|
||||
e.SettingsFilePath,
|
||||
e.SettingsFilePath,
|
||||
ReplacementCharacters.Barebones,
|
||||
Configuration.Instance.ReplacementCharacters,
|
||||
"bak");
|
||||
AudibleApiStorage.EnsureAccountsSettingsFileExists();
|
||||
e.Handled = true;
|
||||
@ -103,6 +119,20 @@ namespace LibationAvalonia.Views
|
||||
|
||||
private async void MainWindow_Opened(object sender, EventArgs e)
|
||||
{
|
||||
if (AudibleFileStorage.BooksDirectory is null)
|
||||
{
|
||||
var result = await MessageBox.Show(
|
||||
this,
|
||||
"Please set a valid Books location in the settings dialog.",
|
||||
"Books Directory Not Set",
|
||||
MessageBoxButtons.OKCancel,
|
||||
MessageBoxIcon.Warning,
|
||||
MessageBoxDefaultButton.Button1);
|
||||
|
||||
if (result is DialogResult.OK)
|
||||
await new SettingsDialog().ShowDialog(this);
|
||||
}
|
||||
|
||||
if (Configuration.Instance.FirstLaunch)
|
||||
{
|
||||
var result = await MessageBox.Show(this, "Would you like a guided tour to get started?", "Libation Walkthrough", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
|
||||
|
||||
@ -5,14 +5,15 @@ using DataLayer;
|
||||
using LibationUiBase;
|
||||
using LibationUiBase.ProcessQueue;
|
||||
|
||||
#nullable enable
|
||||
namespace LibationAvalonia.Views
|
||||
{
|
||||
public delegate void QueueItemPositionButtonClicked(ProcessBookViewModel item, QueuePosition queueButton);
|
||||
public delegate void QueueItemCancelButtonClicked(ProcessBookViewModel item);
|
||||
public delegate void QueueItemPositionButtonClicked(ProcessBookViewModel? item, QueuePosition queueButton);
|
||||
public delegate void QueueItemCancelButtonClicked(ProcessBookViewModel? item);
|
||||
public partial class ProcessBookControl : UserControl
|
||||
{
|
||||
public static event QueueItemPositionButtonClicked PositionButtonClicked;
|
||||
public static event QueueItemCancelButtonClicked CancelButtonClicked;
|
||||
public static event QueueItemPositionButtonClicked? PositionButtonClicked;
|
||||
public static event QueueItemCancelButtonClicked? CancelButtonClicked;
|
||||
|
||||
public static readonly StyledProperty<ProcessBookStatus> ProcessBookStatusProperty =
|
||||
AvaloniaProperty.Register<ProcessBookControl, ProcessBookStatus>(nameof(ProcessBookStatus), enableDataValidation: true);
|
||||
@ -31,12 +32,13 @@ namespace LibationAvalonia.Views
|
||||
{
|
||||
using var context = DbContexts.GetContext();
|
||||
ViewModels.MainVM.Configure_NonUI();
|
||||
DataContext = new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"));
|
||||
if (context.GetLibraryBook_Flat_NoTracking("B017V4IM1G") is LibraryBook book)
|
||||
DataContext = new ProcessBookViewModel(book);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private ProcessBookViewModel DataItem => DataContext is null ? null : DataContext as ProcessBookViewModel;
|
||||
private ProcessBookViewModel? DataItem => DataContext as ProcessBookViewModel;
|
||||
|
||||
public void Cancel_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
=> CancelButtonClicked?.Invoke(DataItem);
|
||||
|
||||
@ -34,44 +34,51 @@ namespace LibationAvalonia.Views
|
||||
var vm = new ProcessQueueViewModel();
|
||||
DataContext = vm;
|
||||
using var context = DbContexts.GetContext();
|
||||
|
||||
|
||||
var trialBook = context.GetLibraryBook_Flat_NoTracking("B017V4IM1G") ?? context.GetLibrary_Flat_NoTracking().FirstOrDefault();
|
||||
if (trialBook is null)
|
||||
return;
|
||||
|
||||
|
||||
List<ProcessBookViewModel> testList = new()
|
||||
{
|
||||
new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"))
|
||||
new ProcessBookViewModel(trialBook)
|
||||
{
|
||||
Result = ProcessBookResult.FailedAbort,
|
||||
Status = ProcessBookStatus.Failed,
|
||||
},
|
||||
new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4IWVG"))
|
||||
new ProcessBookViewModel(trialBook)
|
||||
{
|
||||
Result = ProcessBookResult.FailedSkip,
|
||||
Status = ProcessBookStatus.Failed,
|
||||
},
|
||||
new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4JA2Q"))
|
||||
new ProcessBookViewModel(trialBook)
|
||||
{
|
||||
Result = ProcessBookResult.FailedRetry,
|
||||
Status = ProcessBookStatus.Failed,
|
||||
},
|
||||
new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4NUPO"))
|
||||
new ProcessBookViewModel(trialBook)
|
||||
{
|
||||
Result = ProcessBookResult.ValidationFail,
|
||||
Status = ProcessBookStatus.Failed,
|
||||
},
|
||||
new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4NMX4"))
|
||||
new ProcessBookViewModel(trialBook)
|
||||
{
|
||||
Result = ProcessBookResult.Cancelled,
|
||||
Status = ProcessBookStatus.Cancelled,
|
||||
},
|
||||
new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4NOZ0"))
|
||||
new ProcessBookViewModel(trialBook)
|
||||
{
|
||||
Result = ProcessBookResult.Success,
|
||||
Status = ProcessBookStatus.Completed,
|
||||
},
|
||||
new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6"))
|
||||
new ProcessBookViewModel(trialBook)
|
||||
{
|
||||
Result = ProcessBookResult.None,
|
||||
Status = ProcessBookStatus.Working,
|
||||
},
|
||||
new ProcessBookViewModel(context.GetLibraryBook_Flat_NoTracking("B017V4IM1G"))
|
||||
new ProcessBookViewModel(trialBook)
|
||||
{
|
||||
Result = ProcessBookResult.None,
|
||||
Status = ProcessBookStatus.Queued,
|
||||
@ -99,7 +106,7 @@ namespace LibationAvalonia.Views
|
||||
|
||||
#region Control event handlers
|
||||
|
||||
private async void ProcessBookControl2_CancelButtonClicked(ProcessBookViewModel item)
|
||||
private async void ProcessBookControl2_CancelButtonClicked(ProcessBookViewModel? item)
|
||||
{
|
||||
if (item is not null)
|
||||
{
|
||||
@ -108,19 +115,20 @@ namespace LibationAvalonia.Views
|
||||
}
|
||||
}
|
||||
|
||||
private void ProcessBookControl2_ButtonClicked(ProcessBookViewModel item, QueuePosition queueButton)
|
||||
private void ProcessBookControl2_ButtonClicked(ProcessBookViewModel? item, QueuePosition queueButton)
|
||||
{
|
||||
if (item is not null)
|
||||
Queue?.MoveQueuePosition(item, queueButton);
|
||||
}
|
||||
|
||||
public async void CancelAllBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
public async void CancelAllBtn_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
Queue?.ClearQueue();
|
||||
if (Queue?.Current is not null)
|
||||
await Queue.Current.CancelAsync();
|
||||
}
|
||||
|
||||
public void ClearFinishedBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
public void ClearFinishedBtn_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
Queue?.ClearCompleted();
|
||||
|
||||
@ -128,12 +136,12 @@ namespace LibationAvalonia.Views
|
||||
_viewModel.RunningTime = string.Empty;
|
||||
}
|
||||
|
||||
public void ClearLogBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
public void ClearLogBtn_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
_viewModel?.LogEntries.Clear();
|
||||
}
|
||||
|
||||
private async void LogCopyBtn_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
private async void LogCopyBtn_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||
{
|
||||
if (_viewModel is ProcessQueueViewModel vm)
|
||||
{
|
||||
@ -143,14 +151,14 @@ namespace LibationAvalonia.Views
|
||||
}
|
||||
}
|
||||
|
||||
private async void cancelAllBtn_Click(object sender, EventArgs e)
|
||||
private async void cancelAllBtn_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Queue?.ClearQueue();
|
||||
if (Queue?.Current is not null)
|
||||
await Queue.Current.CancelAsync();
|
||||
}
|
||||
|
||||
private void btnClearFinished_Click(object sender, EventArgs e)
|
||||
private void btnClearFinished_Click(object? sender, EventArgs e)
|
||||
{
|
||||
Queue?.ClearCompleted();
|
||||
|
||||
|
||||
@ -62,25 +62,22 @@ namespace LibationAvalonia.Views
|
||||
if (Design.IsDesignMode)
|
||||
{
|
||||
using var context = DbContexts.GetContext();
|
||||
List<LibraryBook> sampleEntries;
|
||||
LibraryBook?[] sampleEntries;
|
||||
try
|
||||
{
|
||||
sampleEntries = new()
|
||||
{
|
||||
//context.GetLibraryBook_Flat_NoTracking("B00DCD0OXU"),try{
|
||||
sampleEntries = [
|
||||
context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4IWVG"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4JA2Q"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4NUPO"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4NMX4"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017V4NOZ0"),
|
||||
context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6")
|
||||
};
|
||||
context.GetLibraryBook_Flat_NoTracking("B017WJ5ZK6")];
|
||||
}
|
||||
catch { sampleEntries = new(); }
|
||||
catch { sampleEntries = []; }
|
||||
|
||||
var pdvm = new ProductsDisplayViewModel();
|
||||
_ = pdvm.BindToGridAsync(sampleEntries);
|
||||
_ = pdvm.BindToGridAsync(sampleEntries.OfType<LibraryBook>().ToList());
|
||||
DataContext = pdvm;
|
||||
|
||||
setGridScale(1);
|
||||
|
||||
@ -5,6 +5,7 @@ using Avalonia.Controls.Presenters;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Media;
|
||||
using Avalonia.Styling;
|
||||
using Dinah.Core;
|
||||
using Dinah.Core.StepRunner;
|
||||
using LibationAvalonia.Dialogs;
|
||||
using LibationAvalonia.Views;
|
||||
@ -164,7 +165,8 @@ namespace LibationAvalonia
|
||||
{
|
||||
//if we imported new books, wait for the grid to update before proceeding.
|
||||
if (newCount > 0)
|
||||
MainForm.ViewModel.ProductsDisplay.VisibleCountChanged += productsDisplay_VisibleCountChanged;
|
||||
Avalonia.Threading.Dispatcher.UIThread.Invoke(() =>
|
||||
MainForm.ViewModel.ProductsDisplay.VisibleCountChanged += productsDisplay_VisibleCountChanged);
|
||||
else
|
||||
tcs.SetResult();
|
||||
}
|
||||
@ -176,7 +178,7 @@ namespace LibationAvalonia
|
||||
var books = DbContexts.GetLibrary_Flat_NoTracking();
|
||||
if (books.Count == 0) return true;
|
||||
|
||||
var firstAuthor = getFirstAuthor();
|
||||
var firstAuthor = getFirstAuthor()?.SurroundWithQuotes();
|
||||
if (firstAuthor == null) return true;
|
||||
|
||||
if (!await ProceedMessageBox("You can filter the grid entries by searching", "Searching"))
|
||||
@ -193,7 +195,7 @@ namespace LibationAvalonia
|
||||
|
||||
await displayControlAsync(MainForm.filterBtn);
|
||||
|
||||
MainForm.filterBtn.Command.Execute(null);
|
||||
MainForm.filterBtn.Command.Execute(firstAuthor);
|
||||
|
||||
await Task.Delay(1000);
|
||||
|
||||
@ -209,8 +211,7 @@ namespace LibationAvalonia
|
||||
|
||||
private async Task<bool> ShowQuickFilters()
|
||||
{
|
||||
var firstAuthor = getFirstAuthor();
|
||||
|
||||
var firstAuthor = getFirstAuthor()?.SurroundWithQuotes();
|
||||
if (firstAuthor == null) return true;
|
||||
|
||||
if (!await ProceedMessageBox("Queries that you perform regularly can be added to 'Quick Filters'", "Quick Filters"))
|
||||
@ -222,7 +223,7 @@ namespace LibationAvalonia
|
||||
|
||||
await Task.Delay(750);
|
||||
await displayControlAsync(MainForm.addQuickFilterBtn);
|
||||
MainForm.addQuickFilterBtn.Command.Execute(null);
|
||||
MainForm.addQuickFilterBtn.Command.Execute(firstAuthor);
|
||||
await displayControlAsync(MainForm.quickFiltersToolStripMenuItem);
|
||||
await displayControlAsync(editQuickFiltersToolStripMenuItem);
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
using AppScaffolding;
|
||||
using CommandLine;
|
||||
using CommandLine.Text;
|
||||
using LibationFileManager;
|
||||
|
||||
namespace LibationCli;
|
||||
|
||||
@ -20,7 +21,7 @@ internal class HelpVerb
|
||||
{
|
||||
AutoVersion = false,
|
||||
AutoHelp = false,
|
||||
Heading = $"LibationCli v{LibationScaffolding.BuildVersion.ToString(3)}",
|
||||
Heading = $"LibationCli v{LibationScaffolding.BuildVersion.ToVersionString()}",
|
||||
AdditionalNewLineAfterOption = true,
|
||||
MaximumDisplayWidth = 80
|
||||
};
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
using CommandLine;
|
||||
using LibationFileManager;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibationCli
|
||||
@ -6,6 +8,15 @@ namespace LibationCli
|
||||
[Verb("convert", HelpText = "Convert mp4 to mp3.")]
|
||||
public class ConvertOptions : ProcessableOptionsBase
|
||||
{
|
||||
protected override Task ProcessAsync() => RunAsync(CreateProcessable<FileLiberator.ConvertToMp3>());
|
||||
protected override Task ProcessAsync()
|
||||
{
|
||||
if (AudibleFileStorage.BooksDirectory is null)
|
||||
{
|
||||
Console.Error.WriteLine("Error: Books directory is not set. Please configure the 'Books' setting in Settings.json.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
return RunAsync(CreateProcessable<FileLiberator.ConvertToMp3>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
using CommandLine;
|
||||
using DataLayer;
|
||||
using FileLiberator;
|
||||
using LibationFileManager;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace LibationCli
|
||||
@ -13,9 +15,17 @@ namespace LibationCli
|
||||
public bool PdfOnly { get; set; }
|
||||
|
||||
protected override Task ProcessAsync()
|
||||
=> PdfOnly
|
||||
{
|
||||
if (AudibleFileStorage.BooksDirectory is null)
|
||||
{
|
||||
Console.Error.WriteLine("Error: Books directory is not set. Please configure the 'Books' setting in Settings.json.");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
return PdfOnly
|
||||
? RunAsync(CreateProcessable<DownloadPdf>())
|
||||
: RunAsync(CreateBackupBook());
|
||||
}
|
||||
|
||||
private static Processable CreateBackupBook()
|
||||
{
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using AppScaffolding;
|
||||
using CommandLine;
|
||||
using LibationFileManager;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -14,7 +15,7 @@ internal class VersionOptions : OptionsBase
|
||||
protected override Task ProcessAsync()
|
||||
{
|
||||
const string checkingForUpgrade = "Checking for upgrade...";
|
||||
Console.WriteLine($"Libation {LibationScaffolding.Variety} v{LibationScaffolding.BuildVersion.ToString(3)}");
|
||||
Console.WriteLine($"Libation {LibationScaffolding.Variety} v{LibationScaffolding.BuildVersion.ToVersionString()}");
|
||||
|
||||
if (CheckForUpgrade)
|
||||
{
|
||||
@ -34,7 +35,7 @@ internal class VersionOptions : OptionsBase
|
||||
else
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
ReplaceConsoleText(Console.Out, checkingForUpgrade.Length, $"Upgrade Available: v{upgradeProperties.LatestRelease.ToString(3)}");
|
||||
ReplaceConsoleText(Console.Out, checkingForUpgrade.Length, $"Upgrade Available: v{upgradeProperties.LatestRelease.ToVersionString()}");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(upgradeProperties.ZipUrl);
|
||||
|
||||
@ -45,13 +45,24 @@ namespace LibationFileManager
|
||||
|
||||
public static AudioFileStorage Audio { get; } = new AudioFileStorage();
|
||||
|
||||
public static LongPath BooksDirectory
|
||||
/// <summary>
|
||||
/// The fully-qualified Books durectory path if the directory exists, otherwise null.
|
||||
/// </summary>
|
||||
public static LongPath? BooksDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Configuration.Instance.Books))
|
||||
Configuration.Instance.Books = Configuration.DefaultBooksDirectory;
|
||||
return Directory.CreateDirectory(Configuration.Instance.Books).FullName;
|
||||
return null;
|
||||
try
|
||||
{
|
||||
return Directory.CreateDirectory(Configuration.Instance.Books)?.FullName;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Error(ex, "Error creating Books directory: {@BooksDirectory}", Configuration.Instance.Books);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@ -129,8 +140,9 @@ namespace LibationFileManager
|
||||
protected override LongPath? GetFilePathCustom(string productId)
|
||||
=> GetFilePathsCustom(productId).FirstOrDefault();
|
||||
|
||||
private static BackgroundFileSystem newBookDirectoryFiles()
|
||||
=> new BackgroundFileSystem(BooksDirectory, "*.*", SearchOption.AllDirectories);
|
||||
private static BackgroundFileSystem? newBookDirectoryFiles()
|
||||
=> BooksDirectory is LongPath books ? new BackgroundFileSystem(books, "*.*", SearchOption.AllDirectories)
|
||||
: null;
|
||||
|
||||
protected override List<LongPath> GetFilePathsCustom(string productId)
|
||||
{
|
||||
@ -140,6 +152,7 @@ namespace LibationFileManager
|
||||
BookDirectoryFiles = newBookDirectoryFiles();
|
||||
|
||||
var regex = GetBookSearchRegex(productId);
|
||||
var diskFiles = BookDirectoryFiles?.FindFiles(regex) ?? [];
|
||||
|
||||
//Find all extant files matching the productId
|
||||
//using both the file system and the file path cache
|
||||
@ -148,16 +161,16 @@ namespace LibationFileManager
|
||||
.GetFiles(productId)
|
||||
.Where(c => c.fileType == FileType.Audio && File.Exists(c.path))
|
||||
.Select(c => c.path)
|
||||
.Union(BookDirectoryFiles.FindFiles(regex))
|
||||
.Union(diskFiles)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
if (BookDirectoryFiles is null)
|
||||
if (BookDirectoryFiles is null && BooksDirectory is not null)
|
||||
lock (bookDirectoryFilesLocker)
|
||||
BookDirectoryFiles = newBookDirectoryFiles();
|
||||
else
|
||||
|
||||
BookDirectoryFiles?.RefreshFiles();
|
||||
}
|
||||
|
||||
|
||||
@ -16,6 +16,11 @@ namespace LibationFileManager
|
||||
MacOS = 0x400000,
|
||||
}
|
||||
|
||||
public static class Estensions
|
||||
{
|
||||
public static string ToVersionString(this Version version) => version.Revision > 1 ? version.ToString(4) : version.ToString(3);
|
||||
}
|
||||
|
||||
public partial class Configuration
|
||||
{
|
||||
public static bool IsWindows { get; } = OperatingSystem.IsWindows();
|
||||
|
||||
@ -92,23 +92,45 @@ namespace LibationFileManager
|
||||
{nameof(UseWidevine), """
|
||||
Some audiobooks are only delivered in the highest
|
||||
available quality with special, third-party content
|
||||
protection. Enabling this option will make Libation
|
||||
request audiobooks with Widevine DRM, which may
|
||||
yield higher quality audiobook files. If they are
|
||||
higher quality, however, they will also be encoded
|
||||
with a somewhat uncommon codec (xHE-AAC USAC)
|
||||
which you may have difficulty playing.
|
||||
|
||||
This must be enable to download spatial audiobooks.
|
||||
protection. Enabling this option will allows you to
|
||||
request audiobooks in the xHE-AAC codec and in
|
||||
spatial (Dolby Atmos) audio formats.
|
||||
""" },
|
||||
{nameof(Request_xHE_AAC), """
|
||||
If selected, Libation will request audiobooks in the
|
||||
xHE-AAC codec. This codec is generally better quality
|
||||
than AAC-LC codec (which is what you'll get if this
|
||||
option isn't enabled), but it isn't as commonly
|
||||
supported by media players, so you may have some
|
||||
difficulty playing these audiobooks.
|
||||
""" },
|
||||
{nameof(RequestSpatial), """
|
||||
If selected, Libation will request audiobooks in the
|
||||
Dolby Atmos 'Spatial Audio' format. Audiobooks which
|
||||
don't have a spatial audio version will be download
|
||||
as usual based on your other file quality settings.
|
||||
as usual based on your other audio format settings.
|
||||
""" },
|
||||
}
|
||||
.AsReadOnly();
|
||||
{"LocateAudiobooks","""
|
||||
Scan the contents a folder to find audio files that
|
||||
match books in Libation's database. This is useful
|
||||
if you moved your Books folder or re-installed
|
||||
Libation and want it to be able to find your
|
||||
already downloaded audiobooks.
|
||||
|
||||
Prerequisite: An audiobook must already exist in
|
||||
Libation's database (through an Audible account
|
||||
scan) for a matching audio file to be found.
|
||||
""" },
|
||||
{"LocateAudiobooksDialog","""
|
||||
Libation will search all .m4b and .mp3 files in a folder, looking for audio files belonging to library books in Libation's database.
|
||||
|
||||
If an audiobook file is found that matches one of Libation's library books, Libation will mark that book as "Liberated" (green stoplight).
|
||||
|
||||
For an audio file to be identified, Libation must have that library book in its database. If you're on a fresh installation of Libation, be sure to add and scan all of your Audible accounts before running this action.
|
||||
|
||||
This may take a while, depending on the number of audio files in the folder and the speed of your storage device.
|
||||
""" }
|
||||
}.AsReadOnly();
|
||||
|
||||
public static string GetHelpText(string? settingName)
|
||||
=> settingName != null && HelpText.TryGetValue(settingName, out var value) ? value : "";
|
||||
|
||||
@ -84,7 +84,7 @@ namespace LibationFileManager
|
||||
ProcessDirectory,
|
||||
LocalAppData,
|
||||
UserProfile,
|
||||
Path.Combine(Path.GetTempPath(), "Libation")
|
||||
WinTemp,
|
||||
};
|
||||
|
||||
//Try to find and validate appsettings.json in each folder
|
||||
@ -181,7 +181,7 @@ namespace LibationFileManager
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Serilog.Log.Error(e, "Failed to run shell command. {Arguments}", psi.ArgumentList);
|
||||
Serilog.Log.Error(e, "Failed to run shell command. {@Arguments}", psi.ArgumentList);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,6 +27,7 @@ namespace LibationFileManager
|
||||
//https://github.com/serilog/serilog-settings-configuration/issues/406
|
||||
var readerOptions = new ConfigurationReaderOptions(
|
||||
typeof(ILogger).Assembly, // Serilog
|
||||
typeof(LoggerCallerEnrichmentConfiguration).Assembly, // Dinah.Core
|
||||
typeof(LoggerEnrichmentConfigurationExtensions).Assembly, // Serilog.Exceptions
|
||||
typeof(ConsoleLoggerConfigurationExtensions).Assembly, // Serilog.Sinks.Console
|
||||
typeof(FileLoggerConfigurationExtensions).Assembly); // Serilog.Sinks.File
|
||||
|
||||
@ -36,12 +36,12 @@ namespace LibationFileManager
|
||||
|
||||
[return: NotNullIfNotNull(nameof(defaultValue))]
|
||||
public T? GetNonString<T>(T defaultValue, [CallerMemberName] string propertyName = "")
|
||||
=> Settings.GetNonString(propertyName, defaultValue);
|
||||
=> Settings is null ? default : Settings.GetNonString(propertyName, defaultValue);
|
||||
|
||||
|
||||
[return: NotNullIfNotNull(nameof(defaultValue))]
|
||||
public string? GetString(string? defaultValue = null, [CallerMemberName] string propertyName = "")
|
||||
=> Settings.GetString(propertyName, defaultValue);
|
||||
=> Settings?.GetString(propertyName, defaultValue);
|
||||
|
||||
public object? GetObject([CallerMemberName] string propertyName = "") => Settings.GetObject(propertyName);
|
||||
|
||||
@ -111,7 +111,34 @@ namespace LibationFileManager
|
||||
public bool BetaOptIn { get => GetNonString(defaultValue: false); set => SetNonString(value); }
|
||||
|
||||
[Description("Location for book storage. Includes destination of newly liberated books")]
|
||||
public LongPath? Books { get => GetString(); set => SetString(value); }
|
||||
public LongPath? Books {
|
||||
get => GetString();
|
||||
set
|
||||
{
|
||||
if (value != Books)
|
||||
{
|
||||
OnPropertyChanging(nameof(Books), Books, value);
|
||||
Settings.SetString(nameof(Books), value);
|
||||
m_BooksCanWrite255UnicodeChars = null;
|
||||
m_BooksCanWriteWindowsInvalidChars = null;
|
||||
OnPropertyChanged(nameof(Books), value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool? m_BooksCanWrite255UnicodeChars;
|
||||
private bool? m_BooksCanWriteWindowsInvalidChars;
|
||||
/// <summary>
|
||||
/// True if the Books directory can be written to with 255 unicode character filenames
|
||||
/// <para/> Does not persist. Check and set this value at runtime and whenever Books is changed.
|
||||
/// </summary>
|
||||
public bool BooksCanWrite255UnicodeChars => m_BooksCanWrite255UnicodeChars ??= FileSystemTest.CanWrite255UnicodeChars(AudibleFileStorage.BooksDirectory);
|
||||
/// <summary>
|
||||
/// True if the Books directory can be written to with filenames containing characters invalid on Windows (:, *, ?, <, >, |)
|
||||
/// <para/> Always false on Windows platforms.
|
||||
/// <para/> Does not persist. Check and set this value at runtime and whenever Books is changed.
|
||||
/// </summary>
|
||||
public bool BooksCanWriteWindowsInvalidChars => !IsWindows && (m_BooksCanWriteWindowsInvalidChars ??= FileSystemTest.CanWriteWindowsInvalidChars(AudibleFileStorage.BooksDirectory));
|
||||
|
||||
[Description("Overwrite existing files if they already exist?")]
|
||||
public bool OverwriteExisting { get => GetNonString(defaultValue: false); set => SetNonString(value); }
|
||||
@ -258,9 +285,12 @@ namespace LibationFileManager
|
||||
AC_4
|
||||
}
|
||||
|
||||
[Description("Use widevine DRM")]
|
||||
[Description("Use Widevine DRM")]
|
||||
public bool UseWidevine { get => GetNonString(defaultValue: false); set => SetNonString(value); }
|
||||
|
||||
[Description("Request xHE-AAC codec")]
|
||||
public bool Request_xHE_AAC { get => GetNonString(defaultValue: false); set => SetNonString(value); }
|
||||
|
||||
[Description("Request Spatial Audio")]
|
||||
public bool RequestSpatial { get => GetNonString(defaultValue: true); set => SetNonString(value); }
|
||||
|
||||
@ -319,7 +349,7 @@ namespace LibationFileManager
|
||||
#region templates: custom file naming
|
||||
|
||||
[Description("Edit how filename characters are replaced")]
|
||||
public ReplacementCharacters ReplacementCharacters { get => GetNonString(defaultValue: ReplacementCharacters.Default); set => SetNonString(value); }
|
||||
public ReplacementCharacters ReplacementCharacters { get => GetNonString(defaultValue: ReplacementCharacters.Default(IsWindows)); set => SetNonString(value); }
|
||||
|
||||
[Description("How to format the folders in which files will be saved")]
|
||||
public string FolderTemplate
|
||||
|
||||
@ -3,48 +3,58 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using Dinah.Core;
|
||||
using FileManager;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
#nullable enable
|
||||
namespace LibationFileManager
|
||||
{
|
||||
public partial class Configuration : PropertyChangeFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if <see cref="SettingsFilePath"/> exists and the <see cref="Books"/> property has a non-null, non-empty value.
|
||||
/// Does not verify the existence of the <see cref="Books"/> directory.
|
||||
/// </summary>
|
||||
public bool LibationSettingsAreValid => SettingsFileIsValid(SettingsFilePath);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if <paramref name="settingsFile"/> exists and the <see cref="Books"/> property has a non-null, non-empty value.
|
||||
/// Does not verify the existence of the <see cref="Books"/> directory.
|
||||
/// </summary>
|
||||
/// <param name="settingsFile">File path to the settings JSON file</param>
|
||||
public static bool SettingsFileIsValid(string settingsFile)
|
||||
{
|
||||
if (!Directory.Exists(Path.GetDirectoryName(settingsFile)) || !File.Exists(settingsFile))
|
||||
return false;
|
||||
|
||||
var pDic = new PersistentDictionary(settingsFile, isReadOnly: false);
|
||||
|
||||
if (pDic.GetString(nameof(Books)) is not string booksDir)
|
||||
return false;
|
||||
|
||||
if (!Directory.Exists(booksDir))
|
||||
{
|
||||
if (Path.GetDirectoryName(settingsFile) is not string dir)
|
||||
throw new DirectoryNotFoundException(settingsFile);
|
||||
|
||||
//"Books" is not null, so setup has already been run.
|
||||
//Since Books can't be found, try to create it
|
||||
//and then revert to the default books directory
|
||||
foreach (string d in new string[] { booksDir, DefaultBooksDirectory })
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(d);
|
||||
|
||||
pDic.SetString(nameof(Books), d);
|
||||
|
||||
return Directory.Exists(d);
|
||||
var settingsJson = JObject.Parse(File.ReadAllText(settingsFile));
|
||||
return !string.IsNullOrWhiteSpace(settingsJson[nameof(Books)]?.Value<string>());
|
||||
}
|
||||
catch { /* Do Nothing */ }
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Logger.Error(ex, "Failed to load settings file: {@SettingsFile}", settingsFile);
|
||||
try
|
||||
{
|
||||
Serilog.Log.Logger.Information("Deleting invalid settings file: {@SettingsFile}", settingsFile);
|
||||
FileUtility.SaferDelete(settingsFile);
|
||||
Serilog.Log.Logger.Information("Creating a new, empty setting file: {@SettingsFile}", settingsFile);
|
||||
try
|
||||
{
|
||||
File.WriteAllText(settingsFile, "{}");
|
||||
}
|
||||
catch (Exception createEx)
|
||||
{
|
||||
Serilog.Log.Logger.Error(createEx, "Failed to create new settings file: {@SettingsFile}", settingsFile);
|
||||
}
|
||||
}
|
||||
catch (Exception deleteEx)
|
||||
{
|
||||
Serilog.Log.Logger.Error(deleteEx, "Failed to delete the invalid settings file: {@SettingsFile}", settingsFile);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#region singleton stuff
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
using System;
|
||||
using FileManager;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using FileManager;
|
||||
using Newtonsoft.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#nullable enable
|
||||
namespace LibationFileManager
|
||||
@ -32,6 +33,10 @@ namespace LibationFileManager
|
||||
{
|
||||
Cache = JsonConvert.DeserializeObject<FileCacheV2<CacheEntry>>(File.ReadAllText(jsonFileV2))
|
||||
?? throw new NullReferenceException("File exists but deserialize is null. This will never happen when file is healthy.");
|
||||
|
||||
//Once per startup, launch a task to validate existence of files in the cache.
|
||||
//This is fire-and-forget. Since it is never awaited, it will no exceptions will be thrown to the caller.
|
||||
Task.Run(ValidateAllFiles);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -42,6 +47,23 @@ namespace LibationFileManager
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateAllFiles()
|
||||
{
|
||||
bool cacheChanged = false;
|
||||
foreach (var id in Cache.GetIDs())
|
||||
{
|
||||
foreach (var entry in Cache.GetIdEntries(id))
|
||||
{
|
||||
if (!File.Exists(entry.Path))
|
||||
{
|
||||
cacheChanged |= Remove(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cacheChanged)
|
||||
save();
|
||||
}
|
||||
|
||||
public static bool Exists(string id, FileType type) => GetFirstPath(id, type) is not null;
|
||||
|
||||
public static List<(FileType fileType, LongPath path)> GetFiles(string id)
|
||||
@ -111,10 +133,20 @@ namespace LibationFileManager
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void Insert(string id, string path)
|
||||
public static void Insert(string id, params string[] paths)
|
||||
{
|
||||
var type = FileTypes.GetFileTypeFromPath(path);
|
||||
Insert(new CacheEntry(id, type, path));
|
||||
var newEntries
|
||||
= paths
|
||||
.Select(path => new CacheEntry(id, FileTypes.GetFileTypeFromPath(path), path))
|
||||
.ToList();
|
||||
|
||||
lock (locker)
|
||||
Cache.AddRange(id, newEntries);
|
||||
|
||||
if (Inserted is not null)
|
||||
newEntries.ForEach(e => Inserted?.Invoke(null, e));
|
||||
|
||||
save();
|
||||
}
|
||||
|
||||
public static void Insert(CacheEntry entry)
|
||||
@ -150,9 +182,11 @@ namespace LibationFileManager
|
||||
private class FileCacheV2<TEntry>
|
||||
{
|
||||
[JsonProperty]
|
||||
private readonly ConcurrentDictionary<string, List<TEntry>> Dictionary = new();
|
||||
private readonly ConcurrentDictionary<string, HashSet<TEntry>> Dictionary = new();
|
||||
private static object lockObject = new();
|
||||
|
||||
public List<string> GetIDs() => Dictionary.Keys.ToList();
|
||||
|
||||
public List<TEntry> GetIdEntries(string id)
|
||||
{
|
||||
static List<TEntry> empty() => new();
|
||||
@ -162,23 +196,34 @@ namespace LibationFileManager
|
||||
|
||||
public void Add(string id, TEntry entry)
|
||||
{
|
||||
Dictionary.AddOrUpdate(id, [entry], (id, entries) => { entries.Add(entry); return entries; });
|
||||
Dictionary.AddOrUpdate<TEntry>(id,
|
||||
(_, e) => [e], //Add new Dictionary Value
|
||||
(id, existingEntries, newEntry) => //Update existing Dictionary Value
|
||||
{
|
||||
existingEntries.Add(entry);
|
||||
return existingEntries;
|
||||
},
|
||||
entry);
|
||||
}
|
||||
|
||||
public void AddRange(string id, IEnumerable<TEntry> entries)
|
||||
{
|
||||
Dictionary.AddOrUpdate(id, entries.ToList(), (id, entries) =>
|
||||
Dictionary.AddOrUpdate<IEnumerable<TEntry>>(id,
|
||||
(_, e) => e.ToHashSet(), //Add new Dictionary Value
|
||||
(id, existingEntries, newEntries) => //Update existing Dictionary Value
|
||||
{
|
||||
entries.AddRange(entries);
|
||||
return entries;
|
||||
});
|
||||
foreach (var entry in newEntries)
|
||||
existingEntries.Add(entry);
|
||||
return existingEntries;
|
||||
},
|
||||
entries);
|
||||
}
|
||||
|
||||
public bool Remove(string id, TEntry entry)
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
if (Dictionary.TryGetValue(id, out List<TEntry>? entries))
|
||||
if (Dictionary.TryGetValue(id, out HashSet<TEntry>? entries))
|
||||
{
|
||||
var removed = entries?.Remove(entry) ?? false;
|
||||
if (removed && entries?.Count == 0)
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.7" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.8" />
|
||||
<PackageReference Include="NameParserSharp" Version="1.5.0" />
|
||||
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
15
Source/LibationFileManager/Templates/CombinedDto.cs
Normal file
15
Source/LibationFileManager/Templates/CombinedDto.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using AaxDecrypter;
|
||||
|
||||
#nullable enable
|
||||
namespace LibationFileManager.Templates;
|
||||
|
||||
public class CombinedDto
|
||||
{
|
||||
public LibraryBookDto LibraryBook { get; }
|
||||
public MultiConvertFileProperties? MultiConvert { get; }
|
||||
public CombinedDto(LibraryBookDto libraryBook, MultiConvertFileProperties? multiConvert = null)
|
||||
{
|
||||
LibraryBook = libraryBook;
|
||||
MultiConvert = multiConvert;
|
||||
}
|
||||
}
|
||||
@ -1,27 +1,34 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
#nullable enable
|
||||
namespace LibationFileManager.Templates;
|
||||
|
||||
public record SeriesDto : IFormattable
|
||||
public partial record SeriesDto : IFormattable
|
||||
{
|
||||
public string Name { get; }
|
||||
|
||||
public float? Number { get; }
|
||||
public SeriesOrder Order { get; }
|
||||
public string AudibleSeriesId { get; }
|
||||
public SeriesDto(string name, float? number, string audibleSeriesId)
|
||||
public SeriesDto(string name, string? number, string audibleSeriesId)
|
||||
{
|
||||
Name = name;
|
||||
Number = number;
|
||||
Order = SeriesOrder.Parse(number);
|
||||
AudibleSeriesId = audibleSeriesId;
|
||||
}
|
||||
|
||||
public override string ToString() => Name.Trim();
|
||||
public string ToString(string? format, IFormatProvider? _)
|
||||
=> string.IsNullOrWhiteSpace(format) ? ToString()
|
||||
: format
|
||||
: FormatRegex().Replace(format, MatchEvaluator)
|
||||
.Replace("{N}", Name)
|
||||
.Replace("{#}", Number?.ToString())
|
||||
.Replace("{ID}", AudibleSeriesId)
|
||||
.Trim();
|
||||
|
||||
private string MatchEvaluator(Match match)
|
||||
=> Order?.ToString(match.Groups[1].Value, null) ?? "";
|
||||
|
||||
/// <summary> Format must have at least one of the string {N}, {#}, {ID} </summary>
|
||||
[GeneratedRegex(@"{#(?:\:(.*?))?}")]
|
||||
public static partial Regex FormatRegex();
|
||||
}
|
||||
|
||||
@ -12,6 +12,6 @@ internal partial class SeriesListFormat : IListFormat<SeriesListFormat>
|
||||
: IListFormat<SeriesListFormat>.Join(formatString, series);
|
||||
|
||||
/// <summary> Format must have at least one of the string {N}, {#}, {ID} </summary>
|
||||
[GeneratedRegex(@"[Ff]ormat\((.*?(?:{[N#]}|{ID})+.*?)\)")]
|
||||
[GeneratedRegex(@"[Ff]ormat\((.*?(?:{#(?:\:.*?)?}|{N}|{ID})+.*?)\)")]
|
||||
public static partial Regex FormatRegex();
|
||||
}
|
||||
|
||||
88
Source/LibationFileManager/Templates/SeriesOrder.cs
Normal file
88
Source/LibationFileManager/Templates/SeriesOrder.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
|
||||
#nullable enable
|
||||
namespace LibationFileManager.Templates;
|
||||
|
||||
public class SeriesOrder : IFormattable
|
||||
{
|
||||
public object[] OrderParts { get; }
|
||||
private SeriesOrder(object[] orderParts)
|
||||
{
|
||||
OrderParts = orderParts;
|
||||
}
|
||||
|
||||
public override string ToString() => ToString(null, null);
|
||||
|
||||
/// <summary>
|
||||
/// Use float formatters to format the number parts of the order.
|
||||
/// </summary>
|
||||
public string ToString(string? format, IFormatProvider? formatProvider)
|
||||
=> string.Concat(OrderParts.Select(p => p is float f ? f.ToString(format) : p.ToString())).Trim();
|
||||
|
||||
public static SeriesOrder Parse(string? order)
|
||||
{
|
||||
List<object> parts = new();
|
||||
while (TryParseNumber(order, out var value, out var range))
|
||||
{
|
||||
var prefix = order[..range.Start.Value];
|
||||
if(!string.IsNullOrEmpty(prefix))
|
||||
parts.Add(prefix);
|
||||
|
||||
parts.Add(value);
|
||||
|
||||
order = order[range.End.Value..];
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(order))
|
||||
parts.Add(order);
|
||||
|
||||
return new(parts.ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Try to parse any positive number from within the string (greedy).
|
||||
/// </summary>
|
||||
/// <param name="numString">the string to search for a numeric value</param>
|
||||
/// <param name="value">If this function succeeds, the number that was found; otherwise zero.</param>
|
||||
/// <param name="range">If this function succeeds, the range of characters representing <paramref name="value"/> in <paramref name="numString"/>; otherwise default</param>
|
||||
/// <returns>True if a number was found; otherwise false.</returns>
|
||||
private static bool TryParseNumber([NotNullWhen(true)] string? numString, out float value, out Range range)
|
||||
{
|
||||
value = 0;
|
||||
if (string.IsNullOrWhiteSpace(numString))
|
||||
{
|
||||
range = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int s = 0; s < numString.Length; s++)
|
||||
{
|
||||
//Assume any valid number will begin with a digit.
|
||||
//This way, leading dots and dashes will never be considered part of a number, so
|
||||
//no negative series numbers and no fractional series numbers < 1 (unless preceded with a '0').
|
||||
if (!char.IsDigit(numString[s]))
|
||||
continue;
|
||||
|
||||
for (int e = numString.Length; e > s; e--)
|
||||
{
|
||||
//The float parser will succeed with trailing whitespace,
|
||||
//but we want to preserve it in the final display string.
|
||||
if (char.IsWhiteSpace(numString[e - 1]))
|
||||
continue;
|
||||
|
||||
var substring = numString[s..e];
|
||||
if (float.TryParse(substring, System.Globalization.CultureInfo.InvariantCulture, out value))
|
||||
{
|
||||
range = new Range(s, e);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
range = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -68,9 +68,9 @@ namespace LibationFileManager.Templates
|
||||
YearPublished = 2017,
|
||||
Authors = [new("Arthur Conan Doyle", "B000AQ43GQ"), new("Stephen Fry - introductions", "B000APAGVS")],
|
||||
Narrators = [new("Stephen Fry", null)],
|
||||
Series = [new("Sherlock Holmes", 1, "B08376S3R2"), new("Some Other Series", 1, "B000000000")],
|
||||
Series = [new("Sherlock Holmes", "1-6", "B08376S3R2"), new("Book Collection", "1", "B000000000")],
|
||||
Codec = "AAC-LC",
|
||||
LibationVersion = Configuration.LibationVersion?.ToString(3),
|
||||
LibationVersion = Configuration.LibationVersion?.ToVersionString(),
|
||||
FileVersion = "36217811",
|
||||
BitRate = 128,
|
||||
SampleRate = 44100,
|
||||
|
||||
@ -56,5 +56,6 @@ namespace LibationFileManager.Templates
|
||||
public static TemplateTags IfPodcast { get; } = new TemplateTags("if podcast", "Only include if part of a podcast", "<if podcast-><-if podcast>", "<if podcast->...<-if podcast>");
|
||||
public static TemplateTags IfPodcastParent { get; } = new TemplateTags("if podcastparent", "Only include if item is a podcast series parent", "<if podcastparent-><-if podcastparent>", "<if podcastparent->...<-if podcastparent>");
|
||||
public static TemplateTags IfBookseries { get; } = new TemplateTags("if bookseries", "Only include if part of a book series", "<if bookseries-><-if bookseries>", "<if bookseries->...<-if bookseries>");
|
||||
public static TemplateTags Has { get; } = new TemplateTags("has", "Only include if PROPERTY has a value (i.e. not null or empty)", "<has -><-has>", "<has PROPERTY->...<-has>");
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ namespace LibationFileManager.Templates
|
||||
{
|
||||
ArgumentValidator.EnsureNotNull(libraryBookDto, nameof(libraryBookDto));
|
||||
ArgumentValidator.EnsureNotNull(multiChapProps, nameof(multiChapProps));
|
||||
return string.Concat(NamingTemplate.Evaluate(libraryBookDto, multiChapProps).Select(p => p.Value));
|
||||
return string.Concat(NamingTemplate.Evaluate(libraryBookDto, multiChapProps, new CombinedDto(libraryBookDto, multiChapProps)).Select(p => p.Value));
|
||||
}
|
||||
|
||||
public LongPath GetFilename(LibraryBookDto libraryBookDto, string baseDir, string fileExtension, ReplacementCharacters? replacements = null, bool returnFirstExisting = false)
|
||||
@ -138,11 +138,11 @@ namespace LibationFileManager.Templates
|
||||
protected virtual IEnumerable<string> GetTemplatePartsStrings(List<TemplatePart> parts, ReplacementCharacters replacements)
|
||||
=> parts.Select(p => replacements.ReplaceFilenameChars(p.Value));
|
||||
|
||||
private LongPath GetFilename(string baseDir, string fileExtension, ReplacementCharacters replacements, bool returnFirstExisting, params object[] dtos)
|
||||
private LongPath GetFilename(string baseDir, string fileExtension, ReplacementCharacters replacements, bool returnFirstExisting, LibraryBookDto lbDto, MultiConvertFileProperties? multiDto = null)
|
||||
{
|
||||
fileExtension = FileUtility.GetStandardizedExtension(fileExtension);
|
||||
|
||||
var parts = NamingTemplate.Evaluate(dtos).ToList();
|
||||
var parts = NamingTemplate.Evaluate(lbDto, multiDto, new CombinedDto(lbDto, multiDto)).ToList();
|
||||
var pathParts = GetPathParts(GetTemplatePartsStrings(parts, replacements));
|
||||
|
||||
//Remove 1 character from the end of the longest filename part until
|
||||
@ -157,7 +157,7 @@ namespace LibationFileManager.Templates
|
||||
var maxFilenameLength = LongPath.MaxFilenameLength -
|
||||
(i < pathParts.Count - 1 || string.IsNullOrEmpty(fileExtension) ? 0 : fileExtension.Length + 5);
|
||||
|
||||
while (part.Sum(LongPath.GetFilesystemStringLength) > maxFilenameLength)
|
||||
while (part.Sum(GetFilenameLength) > maxFilenameLength)
|
||||
{
|
||||
int maxLength = part.Max(p => p.Length);
|
||||
var maxEntry = part.First(p => p.Length == maxLength);
|
||||
@ -173,6 +173,10 @@ namespace LibationFileManager.Templates
|
||||
return FileUtility.GetValidFilename(fullPath, replacements, fileExtension, returnFirstExisting);
|
||||
}
|
||||
|
||||
private static int GetFilenameLength(string filename)
|
||||
=> Configuration.Instance.BooksCanWrite255UnicodeChars ? filename.Length
|
||||
: System.Text.Encoding.UTF8.GetByteCount(filename);
|
||||
|
||||
/// <summary>
|
||||
/// Organize template parts into directories. Any Extra slashes will be
|
||||
/// returned as empty directories and are taken care of by Path.Combine()
|
||||
@ -267,7 +271,7 @@ namespace LibationFileManager.Templates
|
||||
{ TemplateTags.FirstNarrator, lb => lb.FirstNarrator, FormattableFormatter },
|
||||
{ TemplateTags.Series, lb => lb.Series, SeriesListFormat.Formatter },
|
||||
{ TemplateTags.FirstSeries, lb => lb.FirstSeries, FormattableFormatter },
|
||||
{ TemplateTags.SeriesNumber, lb => lb.FirstSeries?.Number },
|
||||
{ TemplateTags.SeriesNumber, lb => lb.FirstSeries?.Order, FormattableFormatter },
|
||||
{ TemplateTags.Language, lb => lb.Language },
|
||||
//Don't allow formatting of LanguageShort
|
||||
{ TemplateTags.LanguageShort, lb =>lb.Language, getLanguageShort },
|
||||
@ -319,6 +323,35 @@ namespace LibationFileManager.Templates
|
||||
{ TemplateTags.IfBookseries, lb => lb.IsSeries && !lb.IsPodcast && !lb.IsPodcastParent },
|
||||
};
|
||||
|
||||
private static readonly ConditionalTagCollection<CombinedDto> combinedConditionalTags = new()
|
||||
{
|
||||
{ TemplateTags.Has, HasValue}
|
||||
};
|
||||
|
||||
private static bool HasValue(ITemplateTag tag, CombinedDto dtos, string condition)
|
||||
{
|
||||
foreach (var c in chapterPropertyTags.OfType<PropertyTagCollection<LibraryBookDto>>().Append(filePropertyTags).Append(audioFilePropertyTags))
|
||||
{
|
||||
if (c.TryGetValue(condition, dtos.LibraryBook, out var value))
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(value);
|
||||
}
|
||||
}
|
||||
|
||||
if (dtos.MultiConvert is null)
|
||||
return false;
|
||||
|
||||
foreach (var c in chapterPropertyTags.OfType<PropertyTagCollection<MultiConvertFileProperties>>())
|
||||
{
|
||||
if (c.TryGetValue(condition, dtos.MultiConvert, out var value))
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(value);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static readonly ConditionalTagCollection<LibraryBookDto> folderConditionalTags = new()
|
||||
{
|
||||
{ TemplateTags.IfPodcastParent, lb => lb.IsPodcastParent }
|
||||
@ -384,7 +417,7 @@ namespace LibationFileManager.Templates
|
||||
public static string Name { get; } = "Folder Template";
|
||||
public static string Description { get; } = Configuration.GetDescription(nameof(Configuration.FolderTemplate)) ?? "";
|
||||
public static string DefaultTemplate { get; } = "<title short> [<id>]";
|
||||
public static IEnumerable<TagCollection> TagCollections { get; } = [filePropertyTags, audioFilePropertyTags, conditionalTags, folderConditionalTags];
|
||||
public static IEnumerable<TagCollection> TagCollections { get; } = [filePropertyTags, audioFilePropertyTags, conditionalTags, folderConditionalTags, combinedConditionalTags];
|
||||
|
||||
public override IEnumerable<string> Errors
|
||||
=> TemplateText?.Length >= 2 && Path.IsPathFullyQualified(TemplateText) ? base.Errors.Append(ERROR_FULL_PATH_IS_INVALID) : base.Errors;
|
||||
@ -403,7 +436,7 @@ namespace LibationFileManager.Templates
|
||||
public static string Name { get; } = "File Template";
|
||||
public static string Description { get; } = Configuration.GetDescription(nameof(Configuration.FileTemplate)) ?? "";
|
||||
public static string DefaultTemplate { get; } = "<title> [<id>]";
|
||||
public static IEnumerable<TagCollection> TagCollections { get; } = [filePropertyTags, audioFilePropertyTags, conditionalTags];
|
||||
public static IEnumerable<TagCollection> TagCollections { get; } = [filePropertyTags, audioFilePropertyTags, conditionalTags, combinedConditionalTags];
|
||||
}
|
||||
|
||||
public class ChapterFileTemplate : Templates, ITemplate
|
||||
@ -412,7 +445,7 @@ namespace LibationFileManager.Templates
|
||||
public static string Description { get; } = Configuration.GetDescription(nameof(Configuration.ChapterFileTemplate)) ?? "";
|
||||
public static string DefaultTemplate { get; } = "<title> [<id>] - <ch# 0> - <ch title>";
|
||||
public static IEnumerable<TagCollection> TagCollections { get; }
|
||||
= chapterPropertyTags.Append(filePropertyTags).Append(audioFilePropertyTags).Append(conditionalTags);
|
||||
= chapterPropertyTags.Append(filePropertyTags).Append(audioFilePropertyTags).Append(conditionalTags).Append(combinedConditionalTags);
|
||||
|
||||
public override IEnumerable<string> Warnings
|
||||
=> NamingTemplate.TagsInUse.Any(t => t.TagName.In(TemplateTags.ChNumber.TagName, TemplateTags.ChNumber0.TagName))
|
||||
@ -425,7 +458,7 @@ namespace LibationFileManager.Templates
|
||||
public static string Name { get; } = "Chapter Title Template";
|
||||
public static string Description { get; } = Configuration.GetDescription(nameof(Configuration.ChapterTitleTemplate)) ?? "";
|
||||
public static string DefaultTemplate => "<ch#> - <title short>: <ch title>";
|
||||
public static IEnumerable<TagCollection> TagCollections { get; } = chapterPropertyTags.Append(conditionalTags);
|
||||
public static IEnumerable<TagCollection> TagCollections { get; } = chapterPropertyTags.Append(conditionalTags).Append(combinedConditionalTags);
|
||||
|
||||
protected override IEnumerable<string> GetTemplatePartsStrings(List<TemplatePart> parts, ReplacementCharacters replacements)
|
||||
=> parts.Select(p => p.Value);
|
||||
|
||||
@ -46,6 +46,7 @@ namespace LibationSearchEngine
|
||||
{ FieldType.String, lb => lb.Book.UserDefinedItem.Tags, TAGS.FirstCharToUpper() },
|
||||
{ FieldType.String, lb => lb.Book.Locale, "Locale", "Region" },
|
||||
{ FieldType.String, lb => lb.Account, "Account", "Email" },
|
||||
{ FieldType.String, lb => lb.Book.UserDefinedItem.LastDownloadedFormat?.CodecString, "Codec", "DownloadedCodec" },
|
||||
{ FieldType.Bool, lb => lb.Book.HasPdf().ToString(), "HasDownloads", "HasDownload", "Downloads" , "Download", "HasPDFs", "HasPDF" , "PDFs", "PDF" },
|
||||
{ FieldType.Bool, lb => (lb.Book.UserDefinedItem.Rating.OverallRating > 0f).ToString(), "IsRated", "Rated" },
|
||||
{ FieldType.Bool, lb => isAuthorNarrated(lb.Book).ToString(), "IsAuthorNarrated", "AuthorNarrated" },
|
||||
@ -65,6 +66,8 @@ namespace LibationSearchEngine
|
||||
{ FieldType.Number, lb => lb.Book.UserDefinedItem.Rating.OverallRating.ToLuceneString(), "UserRating", "MyRating" },
|
||||
{ FieldType.Number, lb => lb.Book.DatePublished?.ToLuceneString() ?? "", nameof(Book.DatePublished) },
|
||||
{ FieldType.Number, lb => lb.Book.UserDefinedItem.LastDownloaded.ToLuceneString(), nameof(UserDefinedItem.LastDownloaded), "LastDownload" },
|
||||
{ FieldType.Number, lb => lb.Book.UserDefinedItem.LastDownloadedFormat?.BitRate.ToLuceneString(), "Bitrate", "DownloadedBitrate" },
|
||||
{ FieldType.Number, lb => lb.Book.UserDefinedItem.LastDownloadedFormat?.SampleRate.ToLuceneString(), "SampleRate", "DownloadedSampleRate" },
|
||||
{ FieldType.Number, lb => lb.DateAdded.ToLuceneString(), nameof(LibraryBook.DateAdded) }
|
||||
};
|
||||
#endregion
|
||||
|
||||
@ -211,6 +211,24 @@ namespace LibationUiBase.GridView
|
||||
_ => null
|
||||
};
|
||||
|
||||
public bool MemberValueIsDefault(string memberName) => memberName switch
|
||||
{
|
||||
nameof(Series) => Book.SeriesLink?.Any() is not true,
|
||||
nameof(SeriesOrder) => string.IsNullOrWhiteSpace(SeriesOrder.OrderString),
|
||||
nameof(MyRating) => RatingIsDefault(Book.UserDefinedItem.Rating),
|
||||
nameof(ProductRating) => RatingIsDefault(Book.Rating),
|
||||
nameof(Authors) => string.IsNullOrWhiteSpace(Authors),
|
||||
nameof(Narrators) => string.IsNullOrWhiteSpace(Narrators),
|
||||
nameof(Description) => string.IsNullOrWhiteSpace(Description),
|
||||
nameof(Category) => string.IsNullOrWhiteSpace(Category),
|
||||
nameof(Misc) => string.IsNullOrWhiteSpace(Misc),
|
||||
nameof(BookTags) => string.IsNullOrWhiteSpace(BookTags),
|
||||
_ => false
|
||||
};
|
||||
|
||||
private static bool RatingIsDefault(Rating rating)
|
||||
=> rating is null || (rating.OverallRating == 0 && rating.PerformanceRating == 0 && rating.StoryRating == 0);
|
||||
|
||||
public IComparer GetMemberComparer(Type memberType)
|
||||
=> memberTypeComparers.TryGetValue(memberType, out IComparer value) ? value : memberTypeComparers[memberType.BaseType];
|
||||
|
||||
@ -341,7 +359,6 @@ namespace LibationUiBase.GridView
|
||||
return (await Task.WhenAll(tasks)).SelectMany(a => a).ToList();
|
||||
}
|
||||
|
||||
|
||||
~GridEntry()
|
||||
{
|
||||
PictureStorage.PictureCached -= PictureStorage_PictureCached;
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using DataLayer;
|
||||
using LibationFileManager;
|
||||
using System;
|
||||
|
||||
namespace LibationUiBase.GridView
|
||||
@ -10,7 +11,7 @@ namespace LibationUiBase.GridView
|
||||
public string LastDownloadedFileVersion { get; }
|
||||
public Version LastDownloadedVersion { get; }
|
||||
public DateTime? LastDownloaded { get; }
|
||||
public string ToolTipText => IsValid ? $"Double click to open v{LastDownloadedVersion.ToString(3)} release notes" : "";
|
||||
public string ToolTipText => IsValid ? $"Double click to open v{LastDownloadedVersion.ToVersionString()} release notes" : "";
|
||||
|
||||
public LastDownloadStatus() { }
|
||||
public LastDownloadStatus(UserDefinedItem udi)
|
||||
@ -24,14 +25,14 @@ namespace LibationUiBase.GridView
|
||||
public void OpenReleaseUrl()
|
||||
{
|
||||
if (IsValid)
|
||||
Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{LastDownloadedVersion.ToString(3)}");
|
||||
Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{LastDownloadedVersion.ToVersionString()}");
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
=> IsValid ? $"""
|
||||
{dateString()} {versionString()}
|
||||
{LastDownloadedFormat}
|
||||
Libation v{LastDownloadedVersion.ToString(3)}
|
||||
Libation v{LastDownloadedVersion.ToVersionString()}
|
||||
""" : "";
|
||||
|
||||
private string versionString() => LastDownloadedFileVersion is string ver ? $"(File v.{ver})" : "";
|
||||
|
||||
@ -20,10 +20,18 @@ namespace LibationUiBase.GridView
|
||||
protected abstract ListSortDirection GetSortOrder();
|
||||
|
||||
private int InternalCompare(GridEntry x, GridEntry y)
|
||||
{
|
||||
//Default values (e.g. empty strings) always sort to the end of the list.
|
||||
var val1IsDefault = x.MemberValueIsDefault(PropertyName);
|
||||
var val2IsDefault = y.MemberValueIsDefault(PropertyName);
|
||||
|
||||
if (val1IsDefault && val2IsDefault) return 0;
|
||||
else if (val1IsDefault && !val2IsDefault) return GetSortOrder() is ListSortDirection.Ascending ? 1 : -1;
|
||||
else if (!val1IsDefault && val2IsDefault) return GetSortOrder() is ListSortDirection.Ascending ? -1 : 1;
|
||||
else
|
||||
{
|
||||
var val1 = x.GetMemberValue(PropertyName);
|
||||
var val2 = y.GetMemberValue(PropertyName);
|
||||
|
||||
var compare = x.GetMemberComparer(val1.GetType()).Compare(val1, val2);
|
||||
|
||||
return compare == 0 && x.Liberate.IsSeries && y.Liberate.IsSeries
|
||||
@ -31,6 +39,7 @@ namespace LibationUiBase.GridView
|
||||
? x.AudibleProductId.CompareTo(y.AudibleProductId)
|
||||
: compare;
|
||||
}
|
||||
}
|
||||
|
||||
public int Compare(GridEntry? geA, GridEntry? geB)
|
||||
{
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.10" />
|
||||
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.11" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using ApplicationServices;
|
||||
using DataLayer;
|
||||
using LibationFileManager;
|
||||
using LibationUiBase.Forms;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -95,6 +96,9 @@ public class ProcessQueueViewModel : ReactiveObject
|
||||
|
||||
public bool QueueDownloadPdf(IList<LibraryBook> libraryBooks)
|
||||
{
|
||||
if (!IsBooksDirectoryValid())
|
||||
return false;
|
||||
|
||||
var needsPdf = libraryBooks.Where(lb => lb.NeedsPdfDownload()).ToArray();
|
||||
if (needsPdf.Length > 0)
|
||||
{
|
||||
@ -107,6 +111,9 @@ public class ProcessQueueViewModel : ReactiveObject
|
||||
|
||||
public bool QueueConvertToMp3(IList<LibraryBook> libraryBooks)
|
||||
{
|
||||
if (!IsBooksDirectoryValid())
|
||||
return false;
|
||||
|
||||
//Only Queue Liberated books for conversion. This isn't a perfect filter, but it's better than nothing.
|
||||
var preLiberated = libraryBooks.Where(lb => !lb.AbsentFromLastScan && lb.Book.UserDefinedItem.BookStatus is LiberatedStatus.Liberated && lb.Book.ContentType is DataLayer.ContentType.Product).ToArray();
|
||||
if (preLiberated.Length > 0)
|
||||
@ -122,6 +129,9 @@ public class ProcessQueueViewModel : ReactiveObject
|
||||
|
||||
public bool QueueDownloadDecrypt(IList<LibraryBook> libraryBooks)
|
||||
{
|
||||
if (!IsBooksDirectoryValid())
|
||||
return false;
|
||||
|
||||
if (libraryBooks.Count == 1)
|
||||
{
|
||||
var item = libraryBooks[0];
|
||||
@ -157,6 +167,32 @@ public class ProcessQueueViewModel : ReactiveObject
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsBooksDirectoryValid()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(Configuration.Instance.Books))
|
||||
{
|
||||
Serilog.Log.Logger.Error("Books location is not set in configuration.");
|
||||
MessageBoxBase.Show(
|
||||
"Please choose a \"Books location\" folder in the Settings menu.",
|
||||
"Books Directory Not Set",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
else if (AudibleFileStorage.BooksDirectory is null)
|
||||
{
|
||||
Serilog.Log.Logger.Error("Failed to create books directory: {@booksDir}", Configuration.Instance.Books);
|
||||
MessageBoxBase.Show(
|
||||
$"Libation was unable to create the \"Books location\" folder at:\n{Configuration.Instance.Books}\n\nPlease change the Books location in the settings menu.",
|
||||
"Failed to Create Books Directory",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool IsBookInQueue(LibraryBook libraryBook)
|
||||
=> Queue.FirstOrDefault(b => b?.LibraryBook?.Book?.AudibleProductId == libraryBook.Book.AudibleProductId) is not ProcessBookViewModel entry ? false
|
||||
: entry.Status is ProcessBookStatus.Cancelled or ProcessBookStatus.Failed ? !Queue.RemoveCompleted(entry)
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using LibationUiBase;
|
||||
using LibationFileManager;
|
||||
using LibationUiBase;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -38,7 +39,7 @@ namespace LibationWinForms.Dialogs
|
||||
}
|
||||
|
||||
private void releaseNotesLbl_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
=> Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{AppScaffolding.LibationScaffolding.BuildVersion.ToString(3)}");
|
||||
=> Dinah.Core.Go.To.Url($"{AppScaffolding.LibationScaffolding.RepositoryUrl}/releases/tag/v{AppScaffolding.LibationScaffolding.BuildVersion.ToVersionString()}");
|
||||
|
||||
private async void checkForUpgradeBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
@ -50,13 +50,13 @@ namespace LibationWinForms.Dialogs
|
||||
}
|
||||
|
||||
private void loFiDefaultsBtn_Click(object sender, EventArgs e)
|
||||
=> LoadTable(ReplacementCharacters.LoFiDefault.Replacements);
|
||||
=> LoadTable(ReplacementCharacters.LoFiDefault(ntfs: true).Replacements);
|
||||
|
||||
private void defaultsBtn_Click(object sender, EventArgs e)
|
||||
=> LoadTable(ReplacementCharacters.Default.Replacements);
|
||||
=> LoadTable(ReplacementCharacters.Default(ntfs: true).Replacements);
|
||||
|
||||
private void minDefaultBtn_Click(object sender, EventArgs e)
|
||||
=> LoadTable(ReplacementCharacters.Barebones.Replacements);
|
||||
=> LoadTable(ReplacementCharacters.Barebones(ntfs: true).Replacements);
|
||||
|
||||
|
||||
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||
|
||||
@ -28,161 +28,168 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.saveBtn = new System.Windows.Forms.Button();
|
||||
this.cancelBtn = new System.Windows.Forms.Button();
|
||||
this.templateTb = new System.Windows.Forms.TextBox();
|
||||
this.templateLbl = new System.Windows.Forms.Label();
|
||||
this.resetToDefaultBtn = new System.Windows.Forms.Button();
|
||||
this.listView1 = new System.Windows.Forms.ListView();
|
||||
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
|
||||
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
|
||||
this.richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
this.warningsLbl = new System.Windows.Forms.Label();
|
||||
this.exampleLbl = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
saveBtn = new System.Windows.Forms.Button();
|
||||
cancelBtn = new System.Windows.Forms.Button();
|
||||
templateTb = new System.Windows.Forms.TextBox();
|
||||
templateLbl = new System.Windows.Forms.Label();
|
||||
resetToDefaultBtn = new System.Windows.Forms.Button();
|
||||
listView1 = new System.Windows.Forms.ListView();
|
||||
columnHeader1 = new System.Windows.Forms.ColumnHeader();
|
||||
columnHeader2 = new System.Windows.Forms.ColumnHeader();
|
||||
richTextBox1 = new System.Windows.Forms.RichTextBox();
|
||||
warningsLbl = new System.Windows.Forms.Label();
|
||||
exampleLbl = new System.Windows.Forms.Label();
|
||||
llblGoToWiki = new System.Windows.Forms.LinkLabel();
|
||||
SuspendLayout();
|
||||
//
|
||||
// saveBtn
|
||||
//
|
||||
this.saveBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.saveBtn.Location = new System.Drawing.Point(714, 345);
|
||||
this.saveBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.saveBtn.Name = "saveBtn";
|
||||
this.saveBtn.Size = new System.Drawing.Size(88, 27);
|
||||
this.saveBtn.TabIndex = 98;
|
||||
this.saveBtn.Text = "Save";
|
||||
this.saveBtn.UseVisualStyleBackColor = true;
|
||||
this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
|
||||
saveBtn.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
saveBtn.Location = new System.Drawing.Point(714, 345);
|
||||
saveBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
saveBtn.Name = "saveBtn";
|
||||
saveBtn.Size = new System.Drawing.Size(88, 27);
|
||||
saveBtn.TabIndex = 98;
|
||||
saveBtn.Text = "Save";
|
||||
saveBtn.UseVisualStyleBackColor = true;
|
||||
saveBtn.Click += saveBtn_Click;
|
||||
//
|
||||
// cancelBtn
|
||||
//
|
||||
this.cancelBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelBtn.Location = new System.Drawing.Point(832, 345);
|
||||
this.cancelBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.cancelBtn.Name = "cancelBtn";
|
||||
this.cancelBtn.Size = new System.Drawing.Size(88, 27);
|
||||
this.cancelBtn.TabIndex = 99;
|
||||
this.cancelBtn.Text = "Cancel";
|
||||
this.cancelBtn.UseVisualStyleBackColor = true;
|
||||
this.cancelBtn.Click += new System.EventHandler(this.cancelBtn_Click);
|
||||
cancelBtn.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
cancelBtn.Location = new System.Drawing.Point(832, 345);
|
||||
cancelBtn.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
cancelBtn.Name = "cancelBtn";
|
||||
cancelBtn.Size = new System.Drawing.Size(88, 27);
|
||||
cancelBtn.TabIndex = 99;
|
||||
cancelBtn.Text = "Cancel";
|
||||
cancelBtn.UseVisualStyleBackColor = true;
|
||||
cancelBtn.Click += cancelBtn_Click;
|
||||
//
|
||||
// templateTb
|
||||
//
|
||||
this.templateTb.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.templateTb.Location = new System.Drawing.Point(12, 27);
|
||||
this.templateTb.Name = "templateTb";
|
||||
this.templateTb.Size = new System.Drawing.Size(779, 23);
|
||||
this.templateTb.TabIndex = 1;
|
||||
this.templateTb.TextChanged += new System.EventHandler(this.templateTb_TextChanged);
|
||||
templateTb.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
templateTb.Location = new System.Drawing.Point(12, 27);
|
||||
templateTb.Name = "templateTb";
|
||||
templateTb.Size = new System.Drawing.Size(779, 23);
|
||||
templateTb.TabIndex = 1;
|
||||
templateTb.TextChanged += templateTb_TextChanged;
|
||||
//
|
||||
// templateLbl
|
||||
//
|
||||
this.templateLbl.AutoSize = true;
|
||||
this.templateLbl.Location = new System.Drawing.Point(12, 9);
|
||||
this.templateLbl.Name = "templateLbl";
|
||||
this.templateLbl.Size = new System.Drawing.Size(89, 15);
|
||||
this.templateLbl.TabIndex = 0;
|
||||
this.templateLbl.Text = "[template desc]";
|
||||
templateLbl.AutoSize = true;
|
||||
templateLbl.Location = new System.Drawing.Point(12, 9);
|
||||
templateLbl.Name = "templateLbl";
|
||||
templateLbl.Size = new System.Drawing.Size(89, 15);
|
||||
templateLbl.TabIndex = 0;
|
||||
templateLbl.Text = "[template desc]";
|
||||
//
|
||||
// resetToDefaultBtn
|
||||
//
|
||||
this.resetToDefaultBtn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.resetToDefaultBtn.Location = new System.Drawing.Point(797, 26);
|
||||
this.resetToDefaultBtn.Name = "resetToDefaultBtn";
|
||||
this.resetToDefaultBtn.Size = new System.Drawing.Size(124, 23);
|
||||
this.resetToDefaultBtn.TabIndex = 2;
|
||||
this.resetToDefaultBtn.Text = "Reset to default";
|
||||
this.resetToDefaultBtn.UseVisualStyleBackColor = true;
|
||||
this.resetToDefaultBtn.Click += new System.EventHandler(this.resetToDefaultBtn_Click);
|
||||
resetToDefaultBtn.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right;
|
||||
resetToDefaultBtn.Location = new System.Drawing.Point(797, 26);
|
||||
resetToDefaultBtn.Name = "resetToDefaultBtn";
|
||||
resetToDefaultBtn.Size = new System.Drawing.Size(124, 23);
|
||||
resetToDefaultBtn.TabIndex = 2;
|
||||
resetToDefaultBtn.Text = "Reset to default";
|
||||
resetToDefaultBtn.UseVisualStyleBackColor = true;
|
||||
resetToDefaultBtn.Click += resetToDefaultBtn_Click;
|
||||
//
|
||||
// listView1
|
||||
//
|
||||
this.listView1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
|
||||
this.columnHeader1,
|
||||
this.columnHeader2});
|
||||
this.listView1.FullRowSelect = true;
|
||||
this.listView1.GridLines = true;
|
||||
this.listView1.Location = new System.Drawing.Point(12, 56);
|
||||
this.listView1.MultiSelect = false;
|
||||
this.listView1.Name = "listView1";
|
||||
this.listView1.Size = new System.Drawing.Size(328, 283);
|
||||
this.listView1.TabIndex = 3;
|
||||
this.listView1.UseCompatibleStateImageBehavior = false;
|
||||
this.listView1.View = System.Windows.Forms.View.Details;
|
||||
this.listView1.DoubleClick += new System.EventHandler(this.listView1_DoubleClick);
|
||||
listView1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
|
||||
listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { columnHeader1, columnHeader2 });
|
||||
listView1.FullRowSelect = true;
|
||||
listView1.GridLines = true;
|
||||
listView1.Location = new System.Drawing.Point(12, 56);
|
||||
listView1.MultiSelect = false;
|
||||
listView1.Name = "listView1";
|
||||
listView1.Size = new System.Drawing.Size(328, 283);
|
||||
listView1.TabIndex = 3;
|
||||
listView1.UseCompatibleStateImageBehavior = false;
|
||||
listView1.View = System.Windows.Forms.View.Details;
|
||||
listView1.DoubleClick += listView1_DoubleClick;
|
||||
//
|
||||
// columnHeader1
|
||||
//
|
||||
this.columnHeader1.Text = "Tag";
|
||||
this.columnHeader1.Width = 137;
|
||||
columnHeader1.Text = "Tag";
|
||||
columnHeader1.Width = 137;
|
||||
//
|
||||
// columnHeader2
|
||||
//
|
||||
this.columnHeader2.Text = "Description";
|
||||
this.columnHeader2.Width = 170;
|
||||
columnHeader2.Text = "Description";
|
||||
columnHeader2.Width = 170;
|
||||
//
|
||||
// richTextBox1
|
||||
//
|
||||
this.richTextBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.richTextBox1.Location = new System.Drawing.Point(346, 74);
|
||||
this.richTextBox1.Name = "richTextBox1";
|
||||
this.richTextBox1.ReadOnly = true;
|
||||
this.richTextBox1.Size = new System.Drawing.Size(574, 185);
|
||||
this.richTextBox1.TabIndex = 5;
|
||||
this.richTextBox1.Text = "";
|
||||
richTextBox1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
richTextBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
richTextBox1.Location = new System.Drawing.Point(346, 74);
|
||||
richTextBox1.Name = "richTextBox1";
|
||||
richTextBox1.ReadOnly = true;
|
||||
richTextBox1.Size = new System.Drawing.Size(574, 185);
|
||||
richTextBox1.TabIndex = 5;
|
||||
richTextBox1.Text = "";
|
||||
//
|
||||
// warningsLbl
|
||||
//
|
||||
this.warningsLbl.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.warningsLbl.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point);
|
||||
this.warningsLbl.ForeColor = System.Drawing.Color.Firebrick;
|
||||
this.warningsLbl.Location = new System.Drawing.Point(346, 262);
|
||||
this.warningsLbl.Name = "warningsLbl";
|
||||
this.warningsLbl.Size = new System.Drawing.Size(574, 77);
|
||||
this.warningsLbl.TabIndex = 6;
|
||||
this.warningsLbl.Text = "[warnings]";
|
||||
warningsLbl.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
|
||||
warningsLbl.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold);
|
||||
warningsLbl.ForeColor = System.Drawing.Color.Firebrick;
|
||||
warningsLbl.Location = new System.Drawing.Point(346, 262);
|
||||
warningsLbl.Name = "warningsLbl";
|
||||
warningsLbl.Size = new System.Drawing.Size(574, 77);
|
||||
warningsLbl.TabIndex = 6;
|
||||
warningsLbl.Text = "[warnings]";
|
||||
//
|
||||
// exampleLbl
|
||||
//
|
||||
this.exampleLbl.AutoSize = true;
|
||||
this.exampleLbl.Location = new System.Drawing.Point(346, 56);
|
||||
this.exampleLbl.Name = "exampleLbl";
|
||||
this.exampleLbl.Size = new System.Drawing.Size(55, 15);
|
||||
this.exampleLbl.TabIndex = 4;
|
||||
this.exampleLbl.Text = "Example:";
|
||||
exampleLbl.AutoSize = true;
|
||||
exampleLbl.Location = new System.Drawing.Point(346, 56);
|
||||
exampleLbl.Name = "exampleLbl";
|
||||
exampleLbl.Size = new System.Drawing.Size(54, 15);
|
||||
exampleLbl.TabIndex = 4;
|
||||
exampleLbl.Text = "Example:";
|
||||
//
|
||||
// llblGoToWiki
|
||||
//
|
||||
llblGoToWiki.AutoSize = true;
|
||||
llblGoToWiki.Location = new System.Drawing.Point(12, 357);
|
||||
llblGoToWiki.Name = "llblGoToWiki";
|
||||
llblGoToWiki.Size = new System.Drawing.Size(229, 15);
|
||||
llblGoToWiki.TabIndex = 100;
|
||||
llblGoToWiki.TabStop = true;
|
||||
llblGoToWiki.Text = "Read about naming templates on the Wiki";
|
||||
llblGoToWiki.LinkClicked += llblGoToWiki_LinkClicked;
|
||||
//
|
||||
// EditTemplateDialog
|
||||
//
|
||||
this.AcceptButton = this.saveBtn;
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.CancelButton = this.cancelBtn;
|
||||
this.ClientSize = new System.Drawing.Size(933, 388);
|
||||
this.Controls.Add(this.exampleLbl);
|
||||
this.Controls.Add(this.warningsLbl);
|
||||
this.Controls.Add(this.richTextBox1);
|
||||
this.Controls.Add(this.listView1);
|
||||
this.Controls.Add(this.resetToDefaultBtn);
|
||||
this.Controls.Add(this.templateLbl);
|
||||
this.Controls.Add(this.templateTb);
|
||||
this.Controls.Add(this.cancelBtn);
|
||||
this.Controls.Add(this.saveBtn);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "EditTemplateDialog";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Edit Template";
|
||||
this.Load += new System.EventHandler(this.EditTemplateDialog_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
AcceptButton = saveBtn;
|
||||
AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
CancelButton = cancelBtn;
|
||||
ClientSize = new System.Drawing.Size(933, 388);
|
||||
Controls.Add(llblGoToWiki);
|
||||
Controls.Add(exampleLbl);
|
||||
Controls.Add(warningsLbl);
|
||||
Controls.Add(richTextBox1);
|
||||
Controls.Add(listView1);
|
||||
Controls.Add(resetToDefaultBtn);
|
||||
Controls.Add(templateLbl);
|
||||
Controls.Add(templateTb);
|
||||
Controls.Add(cancelBtn);
|
||||
Controls.Add(saveBtn);
|
||||
FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "EditTemplateDialog";
|
||||
StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
Text = "Edit Template";
|
||||
Load += EditTemplateDialog_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@ -198,5 +205,6 @@
|
||||
private System.Windows.Forms.RichTextBox richTextBox1;
|
||||
private System.Windows.Forms.Label warningsLbl;
|
||||
private System.Windows.Forms.Label exampleLbl;
|
||||
private System.Windows.Forms.LinkLabel llblGoToWiki;
|
||||
}
|
||||
}
|
||||
@ -150,5 +150,11 @@ namespace LibationWinForms.Dialogs
|
||||
templateTb.Text = text.Insert(selStart, itemText);
|
||||
templateTb.SelectionStart = selStart + itemText.Length;
|
||||
}
|
||||
|
||||
private void llblGoToWiki_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
Go.To.Url(@"ht" + "tps://github.com/rmcrackan/Libation/blob/master/Documentation/NamingTemplates.md");
|
||||
e.Link.Visited = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,64 @@
|
||||
<root>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
|
||||
@ -83,8 +83,10 @@ namespace LibationWinForms.Dialogs
|
||||
if (lb.Book.UserDefinedItem.BookStatus is not LiberatedStatus.Liberated)
|
||||
await Task.Run(() => lb.UpdateBookStatus(LiberatedStatus.Liberated));
|
||||
|
||||
tokenSource.Token.ThrowIfCancellationRequested();
|
||||
this.Invoke(FileFound, this, book);
|
||||
}
|
||||
catch (OperationCanceledException) { }
|
||||
catch (Exception ex)
|
||||
{
|
||||
Serilog.Log.Error(ex, "Error adding found audiobook file to Libation. {@audioFile}", book);
|
||||
|
||||
@ -25,7 +25,7 @@ namespace LibationWinForms.Dialogs
|
||||
this.moveMoovAtomCbox.Text = desc(nameof(config.MoveMoovToBeginning));
|
||||
this.useWidevineCbox.Text = desc(nameof(config.UseWidevine));
|
||||
this.requestSpatialCbox.Text = desc(nameof(config.RequestSpatial));
|
||||
this.spatialCodecLbl.Text = desc(nameof(config.SpatialAudioCodec));
|
||||
this.request_xHE_AAC_Cbox.Text = desc(nameof(config.Request_xHE_AAC));
|
||||
|
||||
toolTip.SetToolTip(combineNestedChapterTitlesCbox, Configuration.GetHelpText(nameof(config.CombineNestedChapterTitles)));
|
||||
toolTip.SetToolTip(allowLibationFixupCbox, Configuration.GetHelpText(nameof(config.AllowLibationFixup)));
|
||||
@ -38,7 +38,7 @@ namespace LibationWinForms.Dialogs
|
||||
toolTip.SetToolTip(stripAudibleBrandingCbox, Configuration.GetHelpText(nameof(config.StripAudibleBrandAudio)));
|
||||
toolTip.SetToolTip(useWidevineCbox, Configuration.GetHelpText(nameof(config.UseWidevine)));
|
||||
toolTip.SetToolTip(requestSpatialCbox, Configuration.GetHelpText(nameof(config.RequestSpatial)));
|
||||
toolTip.SetToolTip(spatialCodecLbl, Configuration.GetHelpText(nameof(config.SpatialAudioCodec)));
|
||||
toolTip.SetToolTip(request_xHE_AAC_Cbox, Configuration.GetHelpText(nameof(config.Request_xHE_AAC)));
|
||||
toolTip.SetToolTip(spatialAudioCodecCb, Configuration.GetHelpText(nameof(config.SpatialAudioCodec)));
|
||||
|
||||
fileDownloadQualityCb.Items.AddRange(
|
||||
@ -80,6 +80,7 @@ namespace LibationWinForms.Dialogs
|
||||
fileDownloadQualityCb.SelectedItem = config.FileDownloadQuality;
|
||||
spatialAudioCodecCb.SelectedItem = config.SpatialAudioCodec;
|
||||
useWidevineCbox.Checked = config.UseWidevine;
|
||||
request_xHE_AAC_Cbox.Checked = config.Request_xHE_AAC;
|
||||
requestSpatialCbox.Checked = config.RequestSpatial;
|
||||
|
||||
clipsBookmarksFormatCb.SelectedItem = config.ClipsBookmarksFileFormat;
|
||||
@ -124,6 +125,7 @@ namespace LibationWinForms.Dialogs
|
||||
config.DownloadClipsBookmarks = downloadClipsBookmarksCbox.Checked;
|
||||
config.FileDownloadQuality = ((EnumDisplay<Configuration.DownloadQuality>)fileDownloadQualityCb.SelectedItem).Value;
|
||||
config.UseWidevine = useWidevineCbox.Checked;
|
||||
config.Request_xHE_AAC = request_xHE_AAC_Cbox.Checked;
|
||||
config.RequestSpatial = requestSpatialCbox.Checked;
|
||||
config.SpatialAudioCodec = ((EnumDisplay<Configuration.SpatialCodec>)spatialAudioCodecCb.SelectedItem).Value;
|
||||
config.ClipsBookmarksFileFormat = (Configuration.ClipBookmarkFormat)clipsBookmarksFormatCb.SelectedItem;
|
||||
@ -175,6 +177,13 @@ namespace LibationWinForms.Dialogs
|
||||
{
|
||||
moveMoovAtomCbox.Enabled = convertLosslessRb.Checked;
|
||||
lameOptionsGb.Enabled = !convertLosslessRb.Checked;
|
||||
|
||||
if (convertLossyRb.Checked && requestSpatialCbox.Checked)
|
||||
{
|
||||
// Only E-AC-3 can be converted to mp3
|
||||
spatialAudioCodecCb.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
lameTargetRb_CheckedChanged(sender, e);
|
||||
LameMatchSourceBRCbox_CheckedChanged(sender, e);
|
||||
}
|
||||
@ -196,7 +205,18 @@ namespace LibationWinForms.Dialogs
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void spatialAudioCodecCb_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (spatialAudioCodecCb.SelectedIndex == 1 && convertLossyRb.Checked)
|
||||
{
|
||||
// Only E-AC-3 can be converted to mp3
|
||||
spatialAudioCodecCb.SelectedIndex = 0;
|
||||
}
|
||||
}
|
||||
private void requestSpatialCbox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
spatialAudioCodecCb.Enabled = requestSpatialCbox.Checked && useWidevineCbox.Checked;
|
||||
}
|
||||
|
||||
private void useWidevineCbox_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
@ -233,9 +253,13 @@ namespace LibationWinForms.Dialogs
|
||||
return;
|
||||
}
|
||||
}
|
||||
requestSpatialCbox.Enabled = useWidevineCbox.Checked;
|
||||
spatialCodecLbl.Enabled = spatialAudioCodecCb.Enabled = useWidevineCbox.Checked && requestSpatialCbox.Checked;
|
||||
else
|
||||
{
|
||||
requestSpatialCbox.Checked = request_xHE_AAC_Cbox.Checked = false;
|
||||
}
|
||||
|
||||
requestSpatialCbox.Enabled = request_xHE_AAC_Cbox.Enabled = useWidevineCbox.Checked;
|
||||
requestSpatialCbox_CheckedChanged(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,10 +84,10 @@
|
||||
folderTemplateTb = new System.Windows.Forms.TextBox();
|
||||
folderTemplateLbl = new System.Windows.Forms.Label();
|
||||
tab4AudioFileOptions = new System.Windows.Forms.TabPage();
|
||||
request_xHE_AAC_Cbox = new System.Windows.Forms.CheckBox();
|
||||
requestSpatialCbox = new System.Windows.Forms.CheckBox();
|
||||
useWidevineCbox = new System.Windows.Forms.CheckBox();
|
||||
spatialAudioCodecCb = new System.Windows.Forms.ComboBox();
|
||||
spatialCodecLbl = new System.Windows.Forms.Label();
|
||||
moveMoovAtomCbox = new System.Windows.Forms.CheckBox();
|
||||
fileDownloadQualityCb = new System.Windows.Forms.ComboBox();
|
||||
fileDownloadQualityLbl = new System.Windows.Forms.Label();
|
||||
@ -288,7 +288,7 @@
|
||||
stripAudibleBrandingCbox.Location = new System.Drawing.Point(13, 70);
|
||||
stripAudibleBrandingCbox.Name = "stripAudibleBrandingCbox";
|
||||
stripAudibleBrandingCbox.Size = new System.Drawing.Size(143, 34);
|
||||
stripAudibleBrandingCbox.TabIndex = 14;
|
||||
stripAudibleBrandingCbox.TabIndex = 16;
|
||||
stripAudibleBrandingCbox.Text = "[StripAudibleBranding\r\ndesc]";
|
||||
stripAudibleBrandingCbox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
@ -298,7 +298,7 @@
|
||||
splitFilesByChapterCbox.Location = new System.Drawing.Point(13, 22);
|
||||
splitFilesByChapterCbox.Name = "splitFilesByChapterCbox";
|
||||
splitFilesByChapterCbox.Size = new System.Drawing.Size(162, 19);
|
||||
splitFilesByChapterCbox.TabIndex = 12;
|
||||
splitFilesByChapterCbox.TabIndex = 14;
|
||||
splitFilesByChapterCbox.Text = "[SplitFilesByChapter desc]";
|
||||
splitFilesByChapterCbox.UseVisualStyleBackColor = true;
|
||||
splitFilesByChapterCbox.CheckedChanged += splitFilesByChapterCbox_CheckedChanged;
|
||||
@ -311,7 +311,7 @@
|
||||
allowLibationFixupCbox.Location = new System.Drawing.Point(19, 230);
|
||||
allowLibationFixupCbox.Name = "allowLibationFixupCbox";
|
||||
allowLibationFixupCbox.Size = new System.Drawing.Size(162, 19);
|
||||
allowLibationFixupCbox.TabIndex = 11;
|
||||
allowLibationFixupCbox.TabIndex = 13;
|
||||
allowLibationFixupCbox.Text = "[AllowLibationFixup desc]";
|
||||
allowLibationFixupCbox.UseVisualStyleBackColor = true;
|
||||
allowLibationFixupCbox.CheckedChanged += allowLibationFixupCbox_CheckedChanged;
|
||||
@ -323,6 +323,7 @@
|
||||
convertLossyRb.Name = "convertLossyRb";
|
||||
convertLossyRb.Size = new System.Drawing.Size(329, 19);
|
||||
convertLossyRb.TabIndex = 27;
|
||||
convertLossyRb.TabStop = true;
|
||||
convertLossyRb.Text = "Download my books as .MP3 files (transcode if necessary)";
|
||||
convertLossyRb.UseVisualStyleBackColor = true;
|
||||
convertLossyRb.CheckedChanged += convertFormatRb_CheckedChanged;
|
||||
@ -774,10 +775,10 @@
|
||||
// tab4AudioFileOptions
|
||||
//
|
||||
tab4AudioFileOptions.AutoScroll = true;
|
||||
tab4AudioFileOptions.Controls.Add(request_xHE_AAC_Cbox);
|
||||
tab4AudioFileOptions.Controls.Add(requestSpatialCbox);
|
||||
tab4AudioFileOptions.Controls.Add(useWidevineCbox);
|
||||
tab4AudioFileOptions.Controls.Add(spatialAudioCodecCb);
|
||||
tab4AudioFileOptions.Controls.Add(spatialCodecLbl);
|
||||
tab4AudioFileOptions.Controls.Add(moveMoovAtomCbox);
|
||||
tab4AudioFileOptions.Controls.Add(fileDownloadQualityCb);
|
||||
tab4AudioFileOptions.Controls.Add(fileDownloadQualityLbl);
|
||||
@ -802,19 +803,31 @@
|
||||
tab4AudioFileOptions.Text = "Audio File Options";
|
||||
tab4AudioFileOptions.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// request_xHE_AAC_Cbox
|
||||
//
|
||||
request_xHE_AAC_Cbox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
request_xHE_AAC_Cbox.Checked = true;
|
||||
request_xHE_AAC_Cbox.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
request_xHE_AAC_Cbox.Location = new System.Drawing.Point(239, 35);
|
||||
request_xHE_AAC_Cbox.Name = "request_xHE_AAC_Cbox";
|
||||
request_xHE_AAC_Cbox.Size = new System.Drawing.Size(183, 19);
|
||||
request_xHE_AAC_Cbox.TabIndex = 3;
|
||||
request_xHE_AAC_Cbox.Text = "[Request_xHE_AAC desc]";
|
||||
request_xHE_AAC_Cbox.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
request_xHE_AAC_Cbox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// requestSpatialCbox
|
||||
//
|
||||
requestSpatialCbox.AutoSize = true;
|
||||
requestSpatialCbox.CheckAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
requestSpatialCbox.Checked = true;
|
||||
requestSpatialCbox.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
requestSpatialCbox.Location = new System.Drawing.Point(284, 35);
|
||||
requestSpatialCbox.Location = new System.Drawing.Point(19, 60);
|
||||
requestSpatialCbox.Name = "requestSpatialCbox";
|
||||
requestSpatialCbox.Size = new System.Drawing.Size(138, 19);
|
||||
requestSpatialCbox.TabIndex = 29;
|
||||
requestSpatialCbox.TabIndex = 4;
|
||||
requestSpatialCbox.Text = "[RequestSpatial desc]";
|
||||
requestSpatialCbox.UseVisualStyleBackColor = true;
|
||||
requestSpatialCbox.CheckedChanged += useWidevineCbox_CheckedChanged;
|
||||
requestSpatialCbox.CheckedChanged += requestSpatialCbox_CheckedChanged;
|
||||
//
|
||||
// useWidevineCbox
|
||||
//
|
||||
@ -824,7 +837,7 @@
|
||||
useWidevineCbox.Location = new System.Drawing.Point(19, 35);
|
||||
useWidevineCbox.Name = "useWidevineCbox";
|
||||
useWidevineCbox.Size = new System.Drawing.Size(129, 19);
|
||||
useWidevineCbox.TabIndex = 28;
|
||||
useWidevineCbox.TabIndex = 2;
|
||||
useWidevineCbox.Text = "[UseWidevine desc]";
|
||||
useWidevineCbox.UseVisualStyleBackColor = true;
|
||||
useWidevineCbox.CheckedChanged += useWidevineCbox_CheckedChanged;
|
||||
@ -837,16 +850,8 @@
|
||||
spatialAudioCodecCb.Margin = new System.Windows.Forms.Padding(3, 3, 5, 3);
|
||||
spatialAudioCodecCb.Name = "spatialAudioCodecCb";
|
||||
spatialAudioCodecCb.Size = new System.Drawing.Size(173, 23);
|
||||
spatialAudioCodecCb.TabIndex = 2;
|
||||
//
|
||||
// spatialCodecLbl
|
||||
//
|
||||
spatialCodecLbl.AutoSize = true;
|
||||
spatialCodecLbl.Location = new System.Drawing.Point(19, 62);
|
||||
spatialCodecLbl.Name = "spatialCodecLbl";
|
||||
spatialCodecLbl.Size = new System.Drawing.Size(143, 15);
|
||||
spatialCodecLbl.TabIndex = 24;
|
||||
spatialCodecLbl.Text = "[SpatialAudioCodec desc]";
|
||||
spatialAudioCodecCb.TabIndex = 5;
|
||||
spatialAudioCodecCb.SelectedIndexChanged += spatialAudioCodecCb_SelectedIndexChanged;
|
||||
//
|
||||
// moveMoovAtomCbox
|
||||
//
|
||||
@ -875,7 +880,7 @@
|
||||
fileDownloadQualityLbl.Margin = new System.Windows.Forms.Padding(0, 0, 2, 0);
|
||||
fileDownloadQualityLbl.Name = "fileDownloadQualityLbl";
|
||||
fileDownloadQualityLbl.Size = new System.Drawing.Size(152, 15);
|
||||
fileDownloadQualityLbl.TabIndex = 22;
|
||||
fileDownloadQualityLbl.TabIndex = 1;
|
||||
fileDownloadQualityLbl.Text = "[FileDownloadQuality desc]";
|
||||
//
|
||||
// combineNestedChapterTitlesCbox
|
||||
@ -884,7 +889,7 @@
|
||||
combineNestedChapterTitlesCbox.Location = new System.Drawing.Point(19, 206);
|
||||
combineNestedChapterTitlesCbox.Name = "combineNestedChapterTitlesCbox";
|
||||
combineNestedChapterTitlesCbox.Size = new System.Drawing.Size(217, 19);
|
||||
combineNestedChapterTitlesCbox.TabIndex = 10;
|
||||
combineNestedChapterTitlesCbox.TabIndex = 12;
|
||||
combineNestedChapterTitlesCbox.Text = "[CombineNestedChapterTitles desc]";
|
||||
combineNestedChapterTitlesCbox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
@ -895,7 +900,7 @@
|
||||
clipsBookmarksFormatCb.Location = new System.Drawing.Point(285, 132);
|
||||
clipsBookmarksFormatCb.Name = "clipsBookmarksFormatCb";
|
||||
clipsBookmarksFormatCb.Size = new System.Drawing.Size(67, 23);
|
||||
clipsBookmarksFormatCb.TabIndex = 6;
|
||||
clipsBookmarksFormatCb.TabIndex = 9;
|
||||
//
|
||||
// downloadClipsBookmarksCbox
|
||||
//
|
||||
@ -903,7 +908,7 @@
|
||||
downloadClipsBookmarksCbox.Location = new System.Drawing.Point(19, 134);
|
||||
downloadClipsBookmarksCbox.Name = "downloadClipsBookmarksCbox";
|
||||
downloadClipsBookmarksCbox.Size = new System.Drawing.Size(248, 19);
|
||||
downloadClipsBookmarksCbox.TabIndex = 5;
|
||||
downloadClipsBookmarksCbox.TabIndex = 8;
|
||||
downloadClipsBookmarksCbox.Text = "Download Clips, Notes, and Bookmarks as";
|
||||
downloadClipsBookmarksCbox.UseVisualStyleBackColor = true;
|
||||
downloadClipsBookmarksCbox.CheckedChanged += downloadClipsBookmarksCbox_CheckedChanged;
|
||||
@ -916,7 +921,7 @@
|
||||
audiobookFixupsGb.Location = new System.Drawing.Point(6, 254);
|
||||
audiobookFixupsGb.Name = "audiobookFixupsGb";
|
||||
audiobookFixupsGb.Size = new System.Drawing.Size(416, 114);
|
||||
audiobookFixupsGb.TabIndex = 19;
|
||||
audiobookFixupsGb.TabIndex = 14;
|
||||
audiobookFixupsGb.TabStop = false;
|
||||
audiobookFixupsGb.Text = "Audiobook Fix-ups";
|
||||
//
|
||||
@ -926,7 +931,7 @@
|
||||
stripUnabridgedCbox.Location = new System.Drawing.Point(13, 46);
|
||||
stripUnabridgedCbox.Name = "stripUnabridgedCbox";
|
||||
stripUnabridgedCbox.Size = new System.Drawing.Size(147, 19);
|
||||
stripUnabridgedCbox.TabIndex = 13;
|
||||
stripUnabridgedCbox.TabIndex = 15;
|
||||
stripUnabridgedCbox.Text = "[StripUnabridged desc]";
|
||||
stripUnabridgedCbox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
@ -948,7 +953,7 @@
|
||||
chapterTitleTemplateBtn.Location = new System.Drawing.Point(769, 22);
|
||||
chapterTitleTemplateBtn.Name = "chapterTitleTemplateBtn";
|
||||
chapterTitleTemplateBtn.Size = new System.Drawing.Size(75, 23);
|
||||
chapterTitleTemplateBtn.TabIndex = 15;
|
||||
chapterTitleTemplateBtn.TabIndex = 17;
|
||||
chapterTitleTemplateBtn.Text = "Edit...";
|
||||
chapterTitleTemplateBtn.UseVisualStyleBackColor = true;
|
||||
chapterTitleTemplateBtn.Click += chapterTitleTemplateBtn_Click;
|
||||
@ -960,7 +965,7 @@
|
||||
chapterTitleTemplateTb.Name = "chapterTitleTemplateTb";
|
||||
chapterTitleTemplateTb.ReadOnly = true;
|
||||
chapterTitleTemplateTb.Size = new System.Drawing.Size(757, 23);
|
||||
chapterTitleTemplateTb.TabIndex = 16;
|
||||
chapterTitleTemplateTb.TabIndex = 18;
|
||||
//
|
||||
// lameOptionsGb
|
||||
//
|
||||
@ -977,7 +982,7 @@
|
||||
lameOptionsGb.Location = new System.Drawing.Point(438, 78);
|
||||
lameOptionsGb.Name = "lameOptionsGb";
|
||||
lameOptionsGb.Size = new System.Drawing.Size(412, 304);
|
||||
lameOptionsGb.TabIndex = 14;
|
||||
lameOptionsGb.TabIndex = 28;
|
||||
lameOptionsGb.TabStop = false;
|
||||
lameOptionsGb.Text = "Mp3 Encoding Options";
|
||||
//
|
||||
@ -997,7 +1002,7 @@
|
||||
label21.Location = new System.Drawing.Point(227, 75);
|
||||
label21.Name = "label21";
|
||||
label21.Size = new System.Drawing.Size(94, 15);
|
||||
label21.TabIndex = 3;
|
||||
label21.TabIndex = 0;
|
||||
label21.Text = "Encoder Quality:";
|
||||
//
|
||||
// encoderQualityCb
|
||||
@ -1045,7 +1050,7 @@
|
||||
lameBitrateGb.Location = new System.Drawing.Point(6, 100);
|
||||
lameBitrateGb.Name = "lameBitrateGb";
|
||||
lameBitrateGb.Size = new System.Drawing.Size(400, 92);
|
||||
lameBitrateGb.TabIndex = 0;
|
||||
lameBitrateGb.TabIndex = 33;
|
||||
lameBitrateGb.TabStop = false;
|
||||
lameBitrateGb.Text = "Bitrate";
|
||||
//
|
||||
@ -1170,7 +1175,7 @@
|
||||
lameQualityGb.Location = new System.Drawing.Point(6, 196);
|
||||
lameQualityGb.Name = "lameQualityGb";
|
||||
lameQualityGb.Size = new System.Drawing.Size(400, 85);
|
||||
lameQualityGb.TabIndex = 0;
|
||||
lameQualityGb.TabIndex = 36;
|
||||
lameQualityGb.TabStop = false;
|
||||
lameQualityGb.Text = "Quality";
|
||||
//
|
||||
@ -1260,7 +1265,7 @@
|
||||
label13.Location = new System.Drawing.Point(355, 66);
|
||||
label13.Name = "label13";
|
||||
label13.Size = new System.Drawing.Size(39, 15);
|
||||
label13.TabIndex = 1;
|
||||
label13.TabIndex = 0;
|
||||
label13.Text = "Lower";
|
||||
//
|
||||
// label10
|
||||
@ -1269,7 +1274,7 @@
|
||||
label10.Location = new System.Drawing.Point(6, 66);
|
||||
label10.Name = "label10";
|
||||
label10.Size = new System.Drawing.Size(43, 15);
|
||||
label10.TabIndex = 1;
|
||||
label10.TabIndex = 0;
|
||||
label10.Text = "Higher";
|
||||
//
|
||||
// label14
|
||||
@ -1311,7 +1316,7 @@
|
||||
groupBox2.Location = new System.Drawing.Point(6, 22);
|
||||
groupBox2.Name = "groupBox2";
|
||||
groupBox2.Size = new System.Drawing.Size(182, 45);
|
||||
groupBox2.TabIndex = 0;
|
||||
groupBox2.TabIndex = 28;
|
||||
groupBox2.TabStop = false;
|
||||
groupBox2.Text = "Target";
|
||||
//
|
||||
@ -1348,7 +1353,7 @@
|
||||
label1.Location = new System.Drawing.Point(6, 286);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new System.Drawing.Size(172, 15);
|
||||
label1.TabIndex = 1;
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Using L.A.M.E. encoding engine";
|
||||
//
|
||||
// mergeOpeningEndCreditsCbox
|
||||
@ -1357,7 +1362,7 @@
|
||||
mergeOpeningEndCreditsCbox.Location = new System.Drawing.Point(19, 182);
|
||||
mergeOpeningEndCreditsCbox.Name = "mergeOpeningEndCreditsCbox";
|
||||
mergeOpeningEndCreditsCbox.Size = new System.Drawing.Size(198, 19);
|
||||
mergeOpeningEndCreditsCbox.TabIndex = 9;
|
||||
mergeOpeningEndCreditsCbox.TabIndex = 11;
|
||||
mergeOpeningEndCreditsCbox.Text = "[MergeOpeningEndCredits desc]";
|
||||
mergeOpeningEndCreditsCbox.UseVisualStyleBackColor = true;
|
||||
//
|
||||
@ -1367,7 +1372,7 @@
|
||||
retainAaxFileCbox.Location = new System.Drawing.Point(19, 158);
|
||||
retainAaxFileCbox.Name = "retainAaxFileCbox";
|
||||
retainAaxFileCbox.Size = new System.Drawing.Size(131, 19);
|
||||
retainAaxFileCbox.TabIndex = 8;
|
||||
retainAaxFileCbox.TabIndex = 10;
|
||||
retainAaxFileCbox.Text = "[RetainAaxFile desc]";
|
||||
retainAaxFileCbox.UseVisualStyleBackColor = true;
|
||||
retainAaxFileCbox.CheckedChanged += allowLibationFixupCbox_CheckedChanged;
|
||||
@ -1380,7 +1385,7 @@
|
||||
downloadCoverArtCbox.Location = new System.Drawing.Point(19, 110);
|
||||
downloadCoverArtCbox.Name = "downloadCoverArtCbox";
|
||||
downloadCoverArtCbox.Size = new System.Drawing.Size(162, 19);
|
||||
downloadCoverArtCbox.TabIndex = 4;
|
||||
downloadCoverArtCbox.TabIndex = 7;
|
||||
downloadCoverArtCbox.Text = "[DownloadCoverArt desc]";
|
||||
downloadCoverArtCbox.UseVisualStyleBackColor = true;
|
||||
downloadCoverArtCbox.CheckedChanged += allowLibationFixupCbox_CheckedChanged;
|
||||
@ -1393,7 +1398,7 @@
|
||||
createCueSheetCbox.Location = new System.Drawing.Point(19, 86);
|
||||
createCueSheetCbox.Name = "createCueSheetCbox";
|
||||
createCueSheetCbox.Size = new System.Drawing.Size(145, 19);
|
||||
createCueSheetCbox.TabIndex = 3;
|
||||
createCueSheetCbox.TabIndex = 6;
|
||||
createCueSheetCbox.Text = "[CreateCueSheet desc]";
|
||||
createCueSheetCbox.UseVisualStyleBackColor = true;
|
||||
createCueSheetCbox.CheckedChanged += allowLibationFixupCbox_CheckedChanged;
|
||||
@ -1560,8 +1565,8 @@
|
||||
private System.Windows.Forms.GroupBox groupBox1;
|
||||
private System.Windows.Forms.Button applyDisplaySettingsBtn;
|
||||
private System.Windows.Forms.ComboBox spatialAudioCodecCb;
|
||||
private System.Windows.Forms.Label spatialCodecLbl;
|
||||
private System.Windows.Forms.CheckBox useWidevineCbox;
|
||||
private System.Windows.Forms.CheckBox requestSpatialCbox;
|
||||
private System.Windows.Forms.CheckBox request_xHE_AAC_Cbox;
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
#nullable enable
|
||||
namespace LibationWinForms.Dialogs
|
||||
{
|
||||
public partial class SettingsDialog
|
||||
@ -55,7 +56,7 @@ namespace LibationWinForms.Dialogs
|
||||
},
|
||||
Configuration.KnownDirectories.UserProfile,
|
||||
"Books");
|
||||
booksSelectControl.SelectDirectory(config.Books.PathWithoutPrefix);
|
||||
booksSelectControl.SelectDirectory(config.Books?.PathWithoutPrefix ?? "");
|
||||
|
||||
saveEpisodesToSeriesFolderCbox.Checked = config.SavePodcastsToParentFolder;
|
||||
overwriteExistingCbox.Checked = config.OverwriteExisting;
|
||||
@ -63,7 +64,7 @@ namespace LibationWinForms.Dialogs
|
||||
gridFontScaleFactorTbar.Value = scaleFactorToLinearRange(config.GridFontScaleFactor);
|
||||
}
|
||||
|
||||
private void Save_Important(Configuration config)
|
||||
private bool Save_Important(Configuration config)
|
||||
{
|
||||
var newBooks = booksSelectControl.SelectedDirectory;
|
||||
|
||||
@ -73,19 +74,29 @@ namespace LibationWinForms.Dialogs
|
||||
if (string.IsNullOrWhiteSpace(newBooks))
|
||||
{
|
||||
validationError("Cannot set Books Location to blank", "Location is blank");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
LongPath lonNewBooks = newBooks;
|
||||
if (!Directory.Exists(lonNewBooks))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(lonNewBooks);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
validationError($"Error creating Books Location:\r\n{ex.Message}", "Error creating directory");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
LongPath lonNewBooks = newBooks;
|
||||
if (!Directory.Exists(lonNewBooks))
|
||||
Directory.CreateDirectory(lonNewBooks);
|
||||
|
||||
config.Books = newBooks;
|
||||
|
||||
{
|
||||
var logLevelOld = config.LogLevel;
|
||||
var logLevelNew = (Serilog.Events.LogEventLevel)loggingLevelCb.SelectedItem;
|
||||
var logLevelNew = (loggingLevelCb.SelectedItem as Serilog.Events.LogEventLevel?) ?? Serilog.Events.LogEventLevel.Information;
|
||||
|
||||
config.LogLevel = logLevelNew;
|
||||
|
||||
@ -97,9 +108,9 @@ namespace LibationWinForms.Dialogs
|
||||
config.SavePodcastsToParentFolder = saveEpisodesToSeriesFolderCbox.Checked;
|
||||
config.OverwriteExisting = overwriteExistingCbox.Checked;
|
||||
|
||||
|
||||
config.CreationTime = ((EnumDisplay<Configuration.DateTimeSource>)creationTimeCb.SelectedItem).Value;
|
||||
config.LastWriteTime = ((EnumDisplay<Configuration.DateTimeSource>)lastWriteTimeCb.SelectedItem).Value;
|
||||
config.CreationTime = (creationTimeCb.SelectedItem as EnumDisplay<Configuration.DateTimeSource>)?.Value ?? Configuration.DateTimeSource.File;
|
||||
config.LastWriteTime = (lastWriteTimeCb.SelectedItem as EnumDisplay<Configuration.DateTimeSource>)?.Value ?? Configuration.DateTimeSource.File;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int scaleFactorToLinearRange(float scaleFactor)
|
||||
|
||||
@ -43,7 +43,7 @@ namespace LibationWinForms.Dialogs
|
||||
|
||||
private void saveBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
Save_Important(config);
|
||||
if (!Save_Important(config)) return;
|
||||
Save_ImportLibrary(config);
|
||||
Save_DownloadDecrypt(config);
|
||||
Save_AudioSettings(config);
|
||||
|
||||
@ -18,7 +18,7 @@ namespace LibationWinForms.Dialogs
|
||||
|
||||
public UpgradeNotificationDialog(UpgradeProperties upgradeProperties) : this()
|
||||
{
|
||||
Text = $"Libation version {upgradeProperties.LatestRelease.ToString(3)} is now available.";
|
||||
Text = $"Libation version {upgradeProperties.LatestRelease.ToVersionString()} is now available.";
|
||||
PackageUrl = upgradeProperties.ZipUrl;
|
||||
packageDlLink.Text = upgradeProperties.ZipName;
|
||||
releaseNotesTbox.Text = upgradeProperties.Notes;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user