Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Can't get custom language filter to work #36

Closed
Znuff opened this issue Apr 7, 2024 · 3 comments
Closed

[Bug] Can't get custom language filter to work #36

Znuff opened this issue Apr 7, 2024 · 3 comments
Assignees
Labels
bug Something isn't working priority: medium Medium Priority

Comments

@Znuff
Copy link

Znuff commented Apr 7, 2024

Describe the bug
I'm trying to add Romanian to the supported languages, but I can't seem to be able to get it working.

To Reproduce
Steps to reproduce the behavior:

  1. Created file ro-main.json in ~/subclean/filters/ro-main.json
  2. I've added some basic rules to start with:
[
  "regie-live.ro",
  "regielive.ro",
  "www.subtitrari-noi.ro"
]
  1. Verified that my .ro.srt has the strings:
# egrep 'subtitrari-noi|Regie' Stargate\ SG-1\ -\ S10E20\ -\ Unending\ Bluray-1080p.ro.srt
<font color="#8000ff">Subtitrări-Noi Team - www.subtitrari-noi.ro</font>
<font color="#8000ff">Subtitrări-Noi Team - www.subtitrari-noi.ro</font>
www.RegieLive.ro
  1. Run subclean with --debug:
# subclean -w -i Stargate\ SG-1\ -\ S10E20\ -\ Unending\ Bluray-1080p.ro.srt --lang=ro --debug
{
  _: [],
  w: true,
  i: 'Stargate SG-1 - S10E20 - Unending Bluray-1080p.ro.srt',
  lang: 'ro',
  debug: true
}
[debug] readFile: [utf-8] /root/subclean/filters/main.json
[debug] readFile: [utf-8] /root/subclean/filters/users.json
[Info] Language codes matched: .ro.srt,ro
[Filter] [app] Added 140 items from filter 'main'
[Filter] [app] Added 54 items from filter 'users'
[Info] Encoding: utf-8, Language: romanian
[debug] readFile: [utf-8] Stargate SG-1 - S10E20 - Unending Bluray-1080p.ro.srt
[Info] Attempting to load language filters: ro
[debug] readFile: [utf-8] /root/subclean/filters/ro-main.json
[Info] Save file: Stargate SG-1 - S10E20 - Unending Bluray-1080p.ro.srt
[Done] No advertising found

[Debug] 93,120 checks
[Debug] 194 filters applied
[Debug] 480 text nodes
[Info] Save file: /root/subclean/logs/latest.txt
[Filter] [app] Added 3 items from filter 'ro-main.json'
  1. Notice "no advertising found"

Expected behavior
I expect the rules to be picked up and used.

It seems that the ro-main.json file is parsed after the actual subtitle is done?

Version:

# subclean --version
You are using subclean@1.8.0

Additional context
It seems that any "custom" language file rules are loaded after the subtitle is processed. If I move the rules to main.json, they are applied properly:

{
  _: [],
  debug: true,
  lang: 'ro',
  w: true,
  i: 'Stargate SG-1 - S10E20 - Unending Bluray-1080p.ro.srt'
}
[debug] readFile: [utf-8] /root/subclean/filters/main.json
[debug] readFile: [utf-8] /root/subclean/filters/users.json
[Info] Language codes matched: .ro.srt,ro
[Filter] [app] Added 141 items from filter 'main'
[Filter] [app] Added 54 items from filter 'users'
[Info] Encoding: utf-8, Language: romanian
[debug] readFile: [utf-8] Stargate SG-1 - S10E20 - Unending Bluray-1080p.ro.srt
[Info] Attempting to load language filters: ro
[debug] readFile: [utf-8] /root/subclean/filters/ro-main.json
[Match] Advertising found in node 44 (subtitrari-noi.ro)
[Line] <i>ReSincronizare: Agentuoo7</i>
<font color="#8000ff">Subtitrări-Noi Team - www.subtitrari-noi.ro</font>
[Match] Advertising found in node 479 (subtitrari-noi.ro)
[Line] <i>ReSincronizare: Agentuoo7</i>
<font color="#8000ff">Subtitrări-Noi Team - www.subtitrari-noi.ro</font>
[Info] Removed empty nodes: 44, 479
[Info] Save file: Stargate SG-1 - S10E20 - Unending Bluray-1080p.ro.srt
[Done] Removed 2 node(s) and wrote to Stargate SG-1 - S10E20 - Unending Bluray-1080p.ro.srt

[Debug] 93,600 checks
[Debug] 195 filters applied
[Debug] 480 text nodes
[Info] Save file: /root/subclean/logs/latest.txt
[Filter] [app] Added 3 items from filter 'ro-main.json'
@Znuff Znuff added bug Something isn't working priority: medium Medium Priority labels Apr 7, 2024
@DrKain
Copy link
Owner

DrKain commented Apr 7, 2024

Thank you for reporting this error. Could you please upload one of the subtitles that did not work.
At a glance it seems to be an error with another package that parses the file but I will take a look when I can.
I'm very sick at the moment so I can't provide a fix right away. Sorry for the inconvenience.

@Znuff
Copy link
Author

Znuff commented Apr 7, 2024

Sure, here's my ro-main.json attempt (very basic):

ro-main.json

And there's a subtitle file:

Stargate SG-1 - S10E09 - Company of Thieves Bluray-1080p.ro.zip

@DrKain DrKain closed this as completed in 44ed05c May 16, 2024
@DrKain
Copy link
Owner

DrKain commented May 16, 2024

Should be fixed in the latest update. Thank you for reporting and sorry for the slow reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: medium Medium Priority
Projects
None yet
Development

No branches or pull requests

2 participants