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

Added code to remove brackets in file name #9

Merged
merged 3 commits into from
Sep 26, 2018
Merged

Added code to remove brackets in file name #9

merged 3 commits into from
Sep 26, 2018

Conversation

MaciejGorczyca
Copy link
Contributor

@MaciejGorczyca MaciejGorczyca commented Sep 22, 2018

If you are watching movies or other stuff with info in file names such as [1080p], [Translation Group Name] and you want to get rid of it, with this update you can use new config line "exports.ignoreBrackets = true" and all brackets and their content will disappear.

It only removes [ ] and everything between them. It will keep ( ) and other brackets.

I just wanted to add a way to switch it ON and OFF since some people might want to keep the brackets so I added new config line called ignoreBrackets that is boolean type. I added ./config as required in core.js and it's reading the ignoreBracket setting in the same way and in the same place as index.js is reading the port.

I wasn't sure how to do the replace part, so you might keep it as it is or change it to

if (ignoreBrackets) playback.filename = document.getElementById('filepath').textContent.split("\").pop().replace(/ [[^)]] */g, "").trimStr(128);
else playback.filename = document.getElementById('filepath').textContent.split("\").pop().trimStr(128);

edit: fixed regex, was pretty tired last night and didn't have a chance to test it fully...

If you are watching movies or other stuff with info in file names such as [1080p], [Translation Group Name] and you want to get rid of it, with this update you can use new config line "exports.ignoreBrackets = true" and all brackets and their content will disappear.
The regex won't replace whole string into nothing if it's "[text here] other text [text again]"
@liddack
Copy link
Collaborator

liddack commented Sep 23, 2018

Thank you for your PR, it's a really nice addition. There's only one thing in your regex yet to improve.
I did some testing and noticed that if a string has a [brackets section] between words there will be no whitespace separating them, since the regex also removes the whitespaces around brackets.

For instance:
Hilda Official Trailer [HD] Netflix.mp4 becomes Hilda Official TrailerNetflix.mp4.

I guess it will be just fine if we remove only the whitespace(s) before [bracket sections] as in most cases there's no space preceding file extensions (the only case affected by not removing whitespaces after brackets, I suppose).

@liddack liddack self-assigned this Sep 26, 2018
It fixes cases like `Some [brackets] Stuff.mp4` being displayed as `SomeStuff.mp4`
@liddack liddack merged commit 33c4d3e into angeloanan:master Sep 26, 2018
@liddack
Copy link
Collaborator

liddack commented Sep 26, 2018

I went ahead and applied a fix for what I mentioned above, and merged this PR.
I'll add a new Options section to README.md with an overview of each option in config.js (only 2 atm).
And again, thank you for your PR, feel free to send more if you'd like! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants