With the built-in unicode support in Python3, the naming issue is gone.
If you've got some bucks to spend, please give first to SABnzbd and SynoCommunity, then you can think to me
Salut les francophones,
Version en Français de ce tutoriel www.nas-forum.com
[Edit 2nd of October 2013 (version 1.9 is out):
- Fixed an issue with some NZB and Sickbeard option
- In order to simplify the support, the script version is now displayed
[Edit 19th of February 2013 (version 1.8 is out):]
- added Sickbear post-processing
- more evoluate (2 modes) move to a destination folder
- using CP850 code page instead cp437
Hi folks,
As many happy Synology's customers, I'm running a third party SABnzbd client (www.synocommunity.com) on my DS411+.
However there is an painful issue: some NZB contains an archive encoded into a foreign (ISOxxx something) format. So when the archive is unpacked on the NAS (UTF8 encoding style), most of the file containing a foreign character (such as éèçù, etc...) will not be accessible through Samba shares (samba is expecting an UTF8 system files).
This script also provides 4 options:
- Ability to uncompress automatically the .7z archives (Enabled by default).
- Move the SABnzbd folder to a specified destination when the job is done (Disabled by default).
- Added the completed download in the Synology DLNA indexer (Disabled by default).
- Send the job to SickBeard post-processing (Disabled by default).
/!\ Important update announcement!!
Since 2013, the script version 1.9 has been directly included in the SynoCommunity SABnzbd package. Thank to Diaoul !!
From a scratch install, you may directly jump to section 4, then the section Adding folder in the DLNA server if you are concerned.
If you want to upgrade your current version (probably from original 1.3 version), you must go to section 2 and overwrites the existing CharTranslator.py script file.
The default script folder for SABnzbd SynoCommunity package is:
/usr/local/sabnzbd/var/scripts
However the script will be installed only if you don't have a SABnzbd already installed ! The information below is valid only for first time SynoCommunity installation.
If you are updating an existing version, then the full tutorial must be followed. Or you can uninstall SABnzbd and do a fresh install from scratch.
For SynoCommunity package users, please stop SABnzbd service before launching the update.
/!\End of update announcement
TIP: You may use the Mertymade Config File Editor to update the CharTranslator.py script.
Launch the apps from DSM, then select Config File Editor from the list, add the following line at he end (example for SynoCommunity package):
Code: Select all
/usr/local/sabnzbd/var/scripts/CharTranslator.py,CharTrans
Here is the solution to fix this issue, a post-processing script must be executed by SABnzbd:
1- On the [url]http://"your_nas_ip":8080/[/url] GUI (Config -> Folder) , you must setup the Post-Processing Scripts Folder folder. In my case /volume1/download/SABnzbdScripts
2- Create into the specified script folder a CharTranslator.py file (don't forget to setup right access to 755). /!\Warning/!\ this file must be Unix format ! So it is better to create it with vi under a SSH connection.
3- Copy/paste the following script:
When you copy/paste the code below do NOT use the SELECT ALL button, otherwise a tabulation will be added at the beginning of each lines (see this post)
Code can be found here (200,000 characters forum limit... ):
Source code: Version 2.0 Update (2020/09/07)
Off course if you are using an another source than SynoCommunity package, don't forget to update the first line: #!/usr/local/python/bin/python -OO
SPK SynoCommunity:
Code: Select all
#!/usr/local/python/bin/python -OO
Code: Select all
#!/var/packages/pythonutils/target/utils/bin/python -OO
Code: Select all
#!/volume1/@appstore/sab2/utils/bin/python -OO
SPK Zebulon:
Code: Select all
#!/usr/local/python26/bin/python -OO
NB: If you want to create the file from a Window platform, you may use the great editor Notepad++. Don't forget to save the file in Unix format (Edit -> EOL Conversion -> Unix).
PS: The script may also be executed as a command line through a Telnet session.
For example: /volume1/download/SABnzbdScripts/CharTranslator.py "folder path which must be fixed"
If you are executing the command from the folder where is stored the script, the command is
./CharTranslator.py "folder path which must be fixed"
/!\: All extra options must be disable before using it this way (Set all options to False)
Adding folder in the DLNA server:
Some people are using directly the SABnzbd download folder as a final destination (starsys member). A indexing command (synoindex) must be added in order to make visible all downloaded stuffs through the DLNA server.
If you are also locking for this feature, please edit CharTranslator.py and enable the option line 68
Code: Select all
IndexInSynoDLNA = True
Sending folder to SickBeard post-processing:
NB: The script sabToSickBeard.py must be installed first.
The CharTranslator.py will parse the config.ini SABnzbd file to get the scripts folder installation. Then it will check that the autoProcessTV module is available.
Enable this option by editing the line 72
Code: Select all
SickBeardPostProcessing = True
SickBeard GUI -> Config -> Notifications -> Enable 'Synology Indexer'
Moving folder to an another destination:
Enable this option by specifying a destination folder line 51, for ex:
Code: Select all
MoveToThisFolder = '/volume1/video/News'
Change the move mode be editing the line 62; the default value is
Code: Select all
MoveMergeSubFolder = True
- If MoveMergeSubFolder = True (Move/Replace Windows-like), then equivalent to unix command:
cp -rf srcFolder destFolder/
rm -rf srcFolder
In case of conflict between an already existing sub-folder in the destination folder:
the destination sub-folder will be merged with source sub-folder (kind of incremental) - If MoveMergeSubFolder = False (Move Mac OS X-like), then it is equivalent to the Unix cmmand:
rm -rf destFolder
mv -rf srcFolder destFolder
In case of conflict between an already existing sub-folder in the destination folder:
the destination sub-folder will be replaced with source sub-folder
Unpack .7z archive:
It is enabled by default. If you want to disable it, please edit the line 76
Code: Select all
Unpack7z = False
Off course, you can cumulate the option, for example the script can execute the following functions:
1- Unpack all .7z archives.
2- Convert all non-ascii characters to UTF-8 format.
3- Move the completed job to a specified destination.
4- Send it to SickBeard post-processing.
or
1- Unpack all .7z archives.
2- Convert all non-ascii characters to UTF-8 format.
3- Move the completed job to a specified destination.
4- Add multimedia file present in the destination folder into the Synology DLNA indexer.
If you want only the .7z feature with SickBeard:
Edit sabToSickBeard.py file and replace with the following code.
For SynoCommunity users the script is located here:
/usr/local/sickbeard/share/SickBeard/autoProcessTV/
Code: Select all
#!/usr/bin/env python
# Author: Nic Wolfe <[email protected]>
# URL: http://code.google.com/p/sickbeard/
#
# This file is part of Sick Beard.
#
# Sick Beard 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, either version 3 of the License, or
# (at your option) any later version.
#
# Sick Beard 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 Sick Beard. If not, see <http://www.gnu.org/licenses/>.
import sys
import os
import subprocess
import autoProcessTV
# scan .7z files and unpack them
def unpack7zFunc(DirName):
print "Scanning for .7z file(s), then unpack them"
print "Scanning files..."
DetectedFiles = False
for dirname, dirnames, filenames in os.walk(DirName):
for filename in filenames:
if (filename[-3:] == ".7z"):
print "Unpack %s..." %(filename)
DetectedFiles = True
try:
filepath = os.path.join(dirname, filename)
syno7z_cmd = ['/usr/syno/bin/7z', 'x', '-y', filepath]
p = subprocess.Popen(syno7z_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
if (str(out) != ''):
print("7z result: " + filepath + " successfully unpacked")
os.remove(filepath)
print(filepath + " has been deleted")
if (str(err) != ''):
print("7z failed: " + str(err))
except OSError, e:
print("Unable to run 7z: "+str(e))
if DetectedFiles:
print "Scanning for .7z files Done !"
else:
print "No .7z file Detected !"
return
if len(sys.argv) < 2:
print "No folder supplied - is this being called from SABnzbd?"
sys.exit()
else:
os.chdir(sys.argv[1])
currentFolder = os.getcwd()
unpack7zFunc(currentFolder)
autoProcessTV.processEpisode(currentFolder)
If you get an error message such as:
-ash: CharTranslator.py: not found
then you file is probably NOT in Unix format, but in Win format. Keep in minds that end of lines are differnent between Unix and Windows.
Et voilà !!
This script is recursive. So any files/directory will be scan and renamed if necessary.
Please, please, keep me inform if some people has got some issue. You can also post a message if you are happy!!
Have fun folks !!
If every things went well, you should get this message:
Character encoding translation done! (More)
Last comment: even if the script failed to detect correctly the right encoding format, modified files will be accessible from Samba share and File Station. In another words, the biggest risk of using this script is to be constraint to rename files through DSM or Samba. In all case, you don't need anymore to use a Telnet connection to fix its.