Skip to content

Commit

Permalink
reorder_by_original_language [v0.1.0] - rename of reorder_audio_streams2
Browse files Browse the repository at this point in the history
  • Loading branch information
yajrendrag committed Feb 10, 2025
1 parent 62a6452 commit b2ffad1
Show file tree
Hide file tree
Showing 11 changed files with 1,313 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,6 @@
[submodule "source/convert_multichannel_audio_keep_one_codec/lib/ffmpeg"]
path = source/convert_multichannel_audio_keep_one_codec/lib/ffmpeg
url = https://github.com/Josh5/unmanic.plugin.helpers.ffmpeg.git
[submodule "source/reorder_by_original_language/lib/ffmpeg"]
path = source/reorder_by_original_language/lib/ffmpeg
url = https://github.com/Josh5/unmanic.plugin.helpers.ffmpeg.git
4 changes: 4 additions & 0 deletions source/reorder_by_original_language/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/__pycache__
*.py[cod]
**/site-packages
settings.json
674 changes: 674 additions & 0 deletions source/reorder_by_original_language/LICENSE

Large diffs are not rendered by default.

94 changes: 94 additions & 0 deletions source/reorder_by_original_language/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@

**<span style="color:#56adda">0.1.0</span>**
- name change only
- previously known as reorder_audio_streams2

**<span style="color:#56adda">0.0.25</span>**
- stream indicies in copy encoder were incorrect - should have applied enumeration on new_audio_position to determine output stream index
- remove all c:x:y copy and use a single -c copy so that determining new stream index in output file isn't required

**<span style="color:#56adda">0.0.24</span>**
- remove the data['add_file_to_pending_tasks'] = False lines (or set them to None instead) so the remaining plugins' file testing will work

**<span style="color:#56adda">0.0.23</span>**
- prevent file from being added to task queue or from being processed if the result would contain no audio streams

**<span style="color:#56adda">0.0.22</span>**
- reversed index correction from version 0.0.21 (it was correct originally) and put astream_order.remove in a try block

**<span style="color:#56adda">0.0.21</span>**
- add file test check so file is skipped (not added to task queue) if the new audio stream order is the same as original
- correct index on additional_audio_position list comprehension in get_old_and_new_order function so that order is correct on additional audio streams

**<span style="color:#56adda">0.0.20</span>**
- fix typo in lib import statement - missing .lib in path to ffmpeg

**<span style="color:#56adda">0.0.19</span>**
- fix submodule to match changed name of plugin

**<span style="color:#56adda">0.0.18</span>**
- fix probe, parser import line to refer to correct plugin name post plugin name change

**<span style="color:#56adda">0.0.17</span>**
- added fix for allowing more than two 3 letter codes per each 2 letter lookup

**<span style="color:#56adda">0.0.16</span>**
- add option to remove streams not configured to be reordered
- to keep any streams with undefined language tags, add 'und' to end of additional languages field
- any streams without any language tags at all in this scenario will be removed

**<span style="color:#56adda">0.0.15</span>**
- added logging for year2 TypeError and skipping year2 for those file conditions

**<span style="color:#56adda">0.0.14</span>**
- fix missing import re and compiled regex expresssion for PTN excess

**<span style="color:#56adda">0.0.13</span>**
- add workaround for PTN parsing incorrect year

**<span style="color:#56adda">0.0.12</span>**
- guard against empty original_language array in altr

**<span style="color:#56adda">0.0.11</span>**
- add all pages from tmdb query

**<span style="color:#56adda">0.0.10</span>**
- rename plugin to reorder_audio_streams2
- make reordering original languages an option

**<span style="color:#56adda">0.0.9</span>**
- fix unique test function results so only used when more than 1 result found
- add test for equal original languages when more than 1 result found - instead of aborting, just return that original language as they are all the same
- fix library file test to implement reordering when original language not found but additional reordering option is checked

**<span style="color:#56adda">0.0.8</span>**
- add fixes for punctuation in titles
- test both title/name and original_title/original_name for unique match
- refactor unique test into dedicated function

**<span style="color:#56adda">0.0.7</span>**
- added filenames to various logger output to make tracing issues easier

**<span style="color:#56adda">0.0.6</span>**
- add a translation code for 2 letter language 'cn' to same as that for 'zh'

**<span style="color:#56adda">0.0.5</span>**
- make original_language list compatible with multiple original languages when 2 letter code translates to different b & t 3 letter codes

**<span style="color:#56adda">0.0.4</span>**
- add title field variable as tmdb movie title elment an tv title element have different field names
- fix iso-639.2 b & t code parser
- fix add to task queue logic which had a potential KeyError

**<span style="color:#56adda">0.0.3</span>**
- fix year reference in formula to treat as string
- add tasks to queue if original language not found, but additional languages set to restore
- change to parse_torrent_title parser - better parsing
- fix language lookup when table has a '/' to separate multiple options for 3 letter codes

**<span style="color:#56adda">0.0.2</span>**
- add tests to ensure original audio stream is actually in file's audio streams before adding to task queue
- add appropriate log messages for these tests

**<span style="color:#56adda">0.0.1</span>**
- Initial version
60 changes: 60 additions & 0 deletions source/reorder_by_original_language/description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---

##### Links:

- [Support](https://unmanic.app/discord)

---

##### Documentation:

For information on the The Movie Database (tmdb):
- [The Movie Database (tmdb)](https://www.themoviedb.org/)

For more information on language codes:
- [language codes](https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes)

---

##### Description:

This plugin provides multiple options to reorder audio streams. There are 2 checkbox options on the configuration page. Reordering orginal audio indicates that the original audio for
a given file will be the first audio stream. Reordering additional audio languages means that one or more (comma delimited) audio streams can be specified and those audio streams will
be placed in the order listed on the configuration page either as the first audio streams or will be placed behind the original audio stream if both check boxes are checked.

In the case of using original audio, this plugin does a lookup of the original audio language an you will need your own tmdb API - join tmdb and then request an API. The api configuration
has two components - an api_key and an API Read Access Token - you need both. Configure the plugin with both values - they should be clearly labeled.

The original language is moved to be the first audio language and it's disposition is also set to be the default language and all other language dispositions are set to false.

Additionally you may configure a list of additional languages to reorder - this is a comma delimited list and the plugin will reorder these language streams (in the order the appear in the config screen) after the original language.
All remaining language streams will follow these in the order they originally appeared in the file relative to one another.
Specify these addditional languages as a comma delimited list of languages which are most likely to be 3 letter language codes.

The original audio option and the additional audio option can be used separately or together, but one of them must be checked.
---
### Config description:

#### <span style="color:blue">reorder_original_language</span>
Only check this if you wish to make the original audio language the first audio stream. Nothing will change if the original audio stream is not uniquely identified or if it's missing from
the list of audio streams in the file.

#### <span style="color:blue">reorder_additional_audio_streams</span>
Check this if you wish to reorder additional language streams - it can be used with or without checking the reorder original language option.

#### <span style="color:blue">remove_other_languages</span>
Check this if you wish to remove other languages not configured for reordering. If you wish to keep undefined language streams, add "und" (without quotes) to the end
of the reorder_additional_language_streams field. Any audio streams that do not contain a language tag of any kind will be removed if setting this option.

#### <span style="color:blue">library_type</span>
Select TV or Movies for the library type - the plugin can only process a single content type per library. This option is only visible if reorder original audio is checked.

#### <span style="color:blue">"tmdb_api_key</span>
Enter your tmdb api_key. This option is only visible if reorder original audio is checked.

#### <span style="color:blue">"tmdb_api_read_access_token</span>
Enter your tmdb API Read access token (it's a really long string). This option is only visible if reorder original audio is checked.

#### <span style="color:blue">"Search String</span>
enter a comma delimited list of additional languages to be reordered - this is only visible if you check the reorder_additional_audio_streams option above.
These are likely 3 letter codes, e.g., eng, ger (you can enter with spaces or not - it doesn't matter)
Binary file added source/reorder_by_original_language/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions source/reorder_by_original_language/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"author": "yajrendrag",
"compatibility": [
1,
2
],
"description": "Set first audio stream to original audio language, or reorder multiple audio languages or both",
"icon": "https://raw.githubusercontent.com/Josh5/unmanic.plugin.reorder_audio_streams_by_language/master/icon.png",
"id": "reorder_by_original_language",
"name": "Reorder by original language",
"platform": [
"all"
],
"priorities": {
"on_library_management_file_test": 99,
"on_worker_process": 2
},
"tags": "audio,ffmpeg,library file test",
"version": "0.1.0"
}
24 changes: 24 additions & 0 deletions source/reorder_by_original_language/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""
plugins.__init__.py
Written by: Josh.5 <[email protected]>
Date: 23 Aug 2021, (17:30 PM)
Copyright:
Copyright (C) 2021 Josh Sunnex
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General
Public License as published by the Free Software Foundation, version 3.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License along with this program.
If not, see <https://www.gnu.org/licenses/>.
"""

1 change: 1 addition & 0 deletions source/reorder_by_original_language/lib/ffmpeg
Submodule ffmpeg added at 35ae11
Loading

0 comments on commit b2ffad1

Please sign in to comment.