[Synology NAS] Fixed non-ASCII chars and more...(2020/09/11)

Come up with a useful post-processing script? Share it here!
User avatar
LapinFou
Jr. Member
Jr. Member
Posts: 98
Joined: April 23rd, 2012, 7:35 am
Location: France, Caen

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by LapinFou »

J'avais oublié 1 ligne je viens de la rajouter à l'instant !!!
Synology Model: DS-916+
Firmware Version: DSM 6.2.3-25426 Update 2
HDD Model: 3xSeagate ST4000VN008 4To - SHR + 1x256Go SSD - cache

starsys
Newbie
Newbie
Posts: 33
Joined: July 26th, 2011, 4:17 am

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by starsys »

Ça semble passer.
Il manque juste le resultat du script result :

Current folder is/volume1/video/Jenifer - Appelle-moi Jen
Renaming folders to UTF-8...
/volume1/video/Jenifer - Appelle-moi Jen -> No special characters detected: Nothing to be done
Folder renaming Done !

Renaming files to UTF-8...
./Jenifer - Appelle-moi Jen-Back.jpg -> No special characters detected: Nothing to be done
./Jenifer - Appelle-moi Jen-Front.jpg -> No special characters detected: Nothing to be done
./Jenifer - Appelle-moi Jen.nfo -> No special characters detected: Nothing to be done
./08 - Pole Dance.mp3 -> No special characters detected: Nothing to be done
./06 - Le Dos Tourné.mp3 -> ISO-8859-15 detected: Renamed
./02 - Je Danse.mp3 -> No special characters detected: Nothing to be done
./00 - Jenifer - Appelle-moi Jen.m3u -> No special characters detected: Nothing to be done
./01 - A Peine.mp3 -> No special characters detected: Nothing to be done
./05 - Les Autocollants.mp3 -> No special characters detected: Nothing to be done
./10 - Le Risque.mp3 -> No special characters detected: Nothing to be done
./11 - Je Danse (Version Longue).mp3 -> No special characters detected: Nothing to be done
./07 - L'envers Du Paradis.mp3 -> No special characters detected: Nothing to be done
./09 - Pas Que Ça à Faire.mp3 -> ISO-8859-15 detected: Renamed
./04 - L'amour Fou.mp3 -> No special characters detected: Nothing to be done
./03 - La Vérité.mp3 -> ISO-8859-15 detected: Renamed
Files renaming Done !

Adding folder in the DLNA server
Script result:
Script error: None
Character encoding translation done!

starsys
Newbie
Newbie
Posts: 33
Joined: July 26th, 2011, 4:17 am

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by starsys »

Est ce que c normal de rien avoir après "Script result:" ?

User avatar
LapinFou
Jr. Member
Jr. Member
Posts: 98
Joined: April 23rd, 2012, 7:35 am
Location: France, Caen

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by LapinFou »

Cela veut dire que la commande synoindex ne renvoie aucune information. Ce n'est pas forcement anormal. Je vais vérifier ce soir.
Sinon, apriori je dirais que tout a bien fonctionné, car avec le code robuste si la commande s'était mal exécuté tu aurais eu des infos dans Script error.
Au faite cela devrait marque synoindex result
Tu as du commencer à copie le code avant que je fasse la dernière modif... ;)

Je viens de remodifier le code tu post précédent: j'ai ajouté une ligne juste avant la fonction try
Peux-tu essayer à nouveau STP?
Synology Model: DS-916+
Firmware Version: DSM 6.2.3-25426 Update 2
HDD Model: 3xSeagate ST4000VN008 4To - SHR + 1x256Go SSD - cache

starsys
Newbie
Newbie
Posts: 33
Joined: July 26th, 2011, 4:17 am

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by starsys »

je re essaye

User avatar
LapinFou
Jr. Member
Jr. Member
Posts: 98
Joined: April 23rd, 2012, 7:35 am
Location: France, Caen

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by LapinFou »

Sympa ! :)
Merci !!!
Synology Model: DS-916+
Firmware Version: DSM 6.2.3-25426 Update 2
HDD Model: 3xSeagate ST4000VN008 4To - SHR + 1x256Go SSD - cache

starsys
Newbie
Newbie
Posts: 33
Joined: July 26th, 2011, 4:17 am

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by starsys »

Pas d'erreur de script. Je vois pas de changement.
Qu'est ce que tu as modifié ?

Résultat :

Current folder is/volume1/video/Jenifer - Appelle-moi Jen.1
Renaming folders to UTF-8...
/volume1/video/Jenifer - Appelle-moi Jen.1 -> No special characters detected: Nothing to be done
Folder renaming Done !

Renaming files to UTF-8...
./Jenifer - Appelle-moi Jen-Back.jpg -> No special characters detected: Nothing to be done
./Jenifer - Appelle-moi Jen-Front.jpg -> No special characters detected: Nothing to be done
./Jenifer - Appelle-moi Jen.nfo -> No special characters detected: Nothing to be done
./08 - Pole Dance.mp3 -> No special characters detected: Nothing to be done
./06 - Le Dos Tourné.mp3 -> ISO-8859-15 detected: Renamed
./02 - Je Danse.mp3 -> No special characters detected: Nothing to be done
./00 - Jenifer - Appelle-moi Jen.m3u -> No special characters detected: Nothing to be done
./01 - A Peine.mp3 -> No special characters detected: Nothing to be done
./05 - Les Autocollants.mp3 -> No special characters detected: Nothing to be done
./10 - Le Risque.mp3 -> No special characters detected: Nothing to be done
./11 - Je Danse (Version Longue).mp3 -> No special characters detected: Nothing to be done
./07 - L'envers Du Paradis.mp3 -> No special characters detected: Nothing to be done
./09 - Pas Que Ça à Faire.mp3 -> ISO-8859-15 detected: Renamed
./04 - L'amour Fou.mp3 -> No special characters detected: Nothing to be done
./03 - La Vérité.mp3 -> ISO-8859-15 detected: Renamed
Files renaming Done !

Adding folder in the DLNA server
Running: ['/usr/syno/bin/synoindex', '-A', '/volume1/video/Jenifer - Appelle-moi Jen.1']
synoindex result:
synoindex error: None
Character encoding translation done!

User avatar
LapinFou
Jr. Member
Jr. Member
Posts: 98
Joined: April 23rd, 2012, 7:35 am
Location: France, Caen

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by LapinFou »

Cela affiche la commande exécuté:

Code: Select all

Running: ['/usr/syno/bin/synoindex', '-A', '/volume1/video/Jenifer - Appelle-moi Jen.1']
Tiens moi au courant lorsque tu seras rentré chez toi, mais apriori tout c'est parfaitement déroulé.
J'attends ton retour.
Synology Model: DS-916+
Firmware Version: DSM 6.2.3-25426 Update 2
HDD Model: 3xSeagate ST4000VN008 4To - SHR + 1x256Go SSD - cache

User avatar
LapinFou
Jr. Member
Jr. Member
Posts: 98
Joined: April 23rd, 2012, 7:35 am
Location: France, Caen

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by LapinFou »

I've done some testing at home. Seems to be working fine. :)
The finale code is:

Code: Select all

########################
# --- Main Program --- #
########################

# get argument: directory of the SABnzbd job
os.chdir(sys.argv[1])

# display directory of the SABnzbd job
currentFolder = os.getcwd()
print "Current folder is" + currentFolder

# rename SABnzbd job directory (coming from SABnzbd: never in CP437 format)
print "Renaming folders to UTF-8..."
renameFunc('', currentFolder)

# process each sub-folders starting from the deepest level
for dirname, dirnames, filenames in os.walk('.', topdown=False):
	for subdirname in dirnames:
		renameFunc(dirname, subdirname)
print "Folder renaming Done !"
print ""

# process each file recursively
print "Renaming files to UTF-8..."
for dirname, dirnames, filenames in os.walk('.'):
	for filename in filenames:
		renameFunc(dirname, filename)
print "Files renaming Done !"
print ""

# add processed folder in the Syno index database
print "Adding current folder in the DLNA server"
currentFolder = os.getcwd()
synoindex_cmd = ['/usr/syno/bin/synoindex', '-A', currentFolder]
try:
	p = subprocess.Popen(synoindex_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
	out, err = p.communicate()
	if (str(out) == ""):
		print("synoindex result: " + currentFolder + " successfully added to Synology database")
	else:
		tmpBuf = str(out)
		tmpBuf = tmpBuf.split('\n')
		print("synoindex failed: " + tmpBuf[0])
except OSError, e:
	print("Unable to run synoindex: " + str(e))

print "Character encoding translation done!"
Synology Model: DS-916+
Firmware Version: DSM 6.2.3-25426 Update 2
HDD Model: 3xSeagate ST4000VN008 4To - SHR + 1x256Go SSD - cache

starsys
Newbie
Newbie
Posts: 33
Joined: July 26th, 2011, 4:17 am

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by starsys »

Hello.
En fait je fais les tests sur la nas de mes parents car le miens est en sav. Donc je peux pas tester si l'indexation a fonctionné.
As tu fais d'autres changements depuis notre dernier échange cet après midi ?
As tu testé chez toi l'indexation ?
Si tout est ok, je te remercie beaucoup, ça faisait un moment que je me prenais la tête à renommer en manuel en ssh tous les fichiers avec caractères accentués.
Dernier truc qui serait génial : trouver un moyen de lancer une opération de renommage de fichier directement depuis l'interface du syno via un package.
Mertymade avait réussi à le faire à une époque mais ça ne corrigeait pas bien tous les caractères accentués.
Merci encore.

User avatar
LapinFou
Jr. Member
Jr. Member
Posts: 98
Joined: April 23rd, 2012, 7:35 am
Location: France, Caen

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by LapinFou »

Oui cela fonctionne bien chez moi. Et oui j'ai fait qques modifs afin d’intercepter et d'afficher correctement les erreurs envoyé par la commande synoindex.
Prends le code de mon dernier post et tout devrait fonctionner parfaitement. Merci de me tenir au courant lorsque tu auras testé le tout.
Pour ton histoire de renommage je ne comprends pas ce que tu veux dire. En effet tu peux renommer les fichiers depuis FileStation sous DSM.
Synology Model: DS-916+
Firmware Version: DSM 6.2.3-25426 Update 2
HDD Model: 3xSeagate ST4000VN008 4To - SHR + 1x256Go SSD - cache

starsys
Newbie
Newbie
Posts: 33
Joined: July 26th, 2011, 4:17 am

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by starsys »

Je voulais dire renommer en utilisant ton script. Car quand il y a des caractères illégaux dans les noms de fichiers, on ne peux pas les renommer via le filestation mais uniquement en SSH.

User avatar
LapinFou
Jr. Member
Jr. Member
Posts: 98
Joined: April 23rd, 2012, 7:35 am
Location: France, Caen

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by LapinFou »

OK !
Compris. Je regarderais si c'est compliqué d'avoir un bouton sous DSM. Mais pas de suite.
En tout cas merci de me tenir au courant lorsque tu auras fait tourné le bouzin sur ton Syno.
Synology Model: DS-916+
Firmware Version: DSM 6.2.3-25426 Update 2
HDD Model: 3xSeagate ST4000VN008 4To - SHR + 1x256Go SSD - cache

starsys
Newbie
Newbie
Posts: 33
Joined: July 26th, 2011, 4:17 am

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by starsys »

Pas de soucis. Ça fait 8 semaines que j'attends le retour de mon nas en sav. Il devrait plus tarder ... :(
Si je passe chez mes parents avant, je teste. Encore merci.

User avatar
LapinFou
Jr. Member
Jr. Member
Posts: 98
Joined: April 23rd, 2012, 7:35 am
Location: France, Caen

Re: Fixed foreign accents on Synology NAS running SABnzbd

Post by LapinFou »

Tutorial has been updated in order to take in account latest (0.6.15-2) SABnzbd version from SynoCommunity.
Synology Model: DS-916+
Firmware Version: DSM 6.2.3-25426 Update 2
HDD Model: 3xSeagate ST4000VN008 4To - SHR + 1x256Go SSD - cache

Post Reply