aag / apple_trailer_downloader

A script to download HD trailers from the Apple Trailers website.
GNU General Public License v3.0
23 stars 5 forks source link

Illegal filename characters breaks script #3

Closed forthrin closed 8 years ago

forthrin commented 8 years ago

The script needs to be updated so as to replace characters illegal in filenames with other characters. For example, at the time of posting this issue, the movie "Hitchcock/Truffaut" contained in the "Just added" section halts the script because the slash (a path separator) creates confusion.

Checking for Hitchcock/Truffaut
downloading http://movietrailers.apple.com/movies/independent/hitchcocktruffaut/hitchcocktruffaut-tlr1_h1080p.mov
Saving file to /Users/name/Movies/Trailers/Hitchcock/Truffaut.Trailer.1080p.mov
Traceback (most recent call last):
  File "/Users/name/bin/trailer.py", line 259, in <module>
    downloadTrailerFromPage(url, trailer['title'], dlListPath, config['resolution'], config['download_dir'])
  File "/Users/name/bin/trailer.py", line 170, in downloadTrailerFromPage
    downloadTrailerFile(trailerUrl, destdir, trailerFileName)
  File "/Users/name/bin/trailer.py", line 157, in downloadTrailerFile
    with open(filePath, 'wb') as fp:
IOError: [Errno 2] No such file or directory: u'/Users/name/Movies/Trailers/Hitchcock/Truffaut.Trailer.1080p.mov'

Note also: A related problem is true for the movie "The Hunger Games/ Mockingjay, Part 2". In this case the slash actually makes it into the filename, though I think most would agree filenames should not have slashes in them, so this should be fixed too.

aag commented 8 years ago

Thanks for the bug report. The problem has been fixed in commit 64b516ef82891230d7b78728c44fb05adec3ab49. Now the script removes all problematic characters from the filename. I tested it with the two pages you listed in the issue and they seem to be working now.

Hopefully I covered all the troublesome characters, but please let me know if you run into any other trailers with similar issues.