dbr / tvnamer

Automatic TV episode file renamer, uses data from thetvdb.com via tvdb_api
https://pypi.python.org/pypi/tvnamer/
The Unlicense
912 stars 115 forks source link

Episodes with puctuation marks cause OSError(22, 'Invalid argument') #61

Closed mcclurec closed 11 years ago

mcclurec commented 11 years ago

I was cleaning up some episodes from It's Always Sunny in Philadelphia, and a handful wouldn't rename. What I look on TVDB, all the episode names have punctuation like colons or question marks. I believe TVNamer is trying to pass these through unescaped, and it's causing the failure. Here's a sample below.

####################
# Processing file: It's Always Sunny In Philadelphia - [S06E07].avi
# Detected series: It's Always Sunny In Philadelphia (season: 6, episode: 7)
####################
Old filename: It's Always Sunny In Philadelphia - [S06E07].avi
New filename: It's Always Sunny in Philadelphia - [S06E07] - Who Got Dee Pregnant?.avi
OSError(22, 'Invalid argument')
New path: /media/ARES/TV Shows/It's Always Sunny in Philadelphia/It's Always Sunny In Philadelphia - [S06E07].avi
Creating directory /media/ARES/TV Shows/It's Always Sunny in Philadelphia
OSError(u"File /media/ARES/TV Shows/It's Always Sunny in Philadelphia/It's Always Sunny In Philadelphia - [S06E07].avi already exists, not forcefully moving /media/ARES/TV Shows/It's Always Sunny in Philadelphia/It's Always Sunny In Philadelphia - [S06E07].avi",)

Episodes 5,7,9 & 10 of season six all have punctuation and all are failing the same way. Here's a link to the episode guide. http://thetvdb.com/?tab=season&seriesid=75805&seasonid=268951&lid=7

On a side note: Thanks for this fantastic script. It's exactly what I needed.

dbr commented 11 years ago

That's weird. What filesystem are these files on?

If it's a default'ish one like Ext4, it work fine with any character except a null byte and a slash. If you are on Linux, tvnamer assumes it's your filesystem is like this (and only removes \0 and /)

If you are using something like a FAT32 NAS drive, that would explain this error.

If it is FAT32/NTFS, you can use the windows_safe_filenames config option. Alternatively you can use custom_filename_character_blacklist to remove specific characters, or the replacements to do more specific cleanup

dbr commented 11 years ago

That's weird. What OS and filesystem are you using? I assume it's Linux based on the path

If so, Ext4 and similar filesystems typically accept any character except a null-byte and / - both are removed.

If you are using a filesystem like FAT32 (common for volumes mounted from NAS devices), that would explain this error. tvnamer sanitises for Ext4'ish FS, and has no idea you are writing to a device with more limited filenames

A few options, if this is the problem:

mcclurec commented 11 years ago

Ahh, this particular drive is a FAT 32. I have a mixed disk environment on Ubuntu 12.04. I’ll probably just use the "windows_safe_filenames": true option. I wasn’t thinking that I’d need that on a linux system, but I forgot about the joys of still having a FAT 32 drive laying around. It might be time to back that up and reformat it. Thanks for the speedy reply.

Colin

From: dbr [mailto:notifications@github.com] Sent: Tuesday, December 11, 2012 3:37 AM To: dbr/tvnamer Cc: mcclurec Subject: Re: [tvnamer] Episodes with puctuation marks cause OSError(22, 'Invalid argument') (#61)

That's weird. What OS and filesystem are you using? I assume it's Linux based on the path

If so, Ext4 and similar filesystems typically accept any character except a null-byte and / - both are removed.

If you are using a filesystem like FAT32 (common for volumes mounted from NAS devices), that would explain this error. tvnamer sanitises for Ext4'ish FS, and has no idea you are writing to a device with more limited filenames

A few options, if this is the problem:

— Reply to this email directly or view it on GitHub https://github.com/dbr/tvnamer/issues/61#issuecomment-11240346 .

https://github.com/notifications/beacon/OHFj-wsNBKDF_cCQsF1D2TFALqQO-sQs3J_h1g4aBIX0F3aUlmLuYgn0L-8-nbV4.gif