Giter Site home page Giter Site logo

meermanr / tvseriesrenamer Goto Github PK

View Code? Open in Web Editor NEW
41.0 41.0 7.0 27.39 MB

Script for renaming files in a digital video collection. Automatically fetches episode titles from the web.

Home Page: http://www.robmeerman.co.uk/coding/file_renamer

Python 6.42% Perl 92.96% Dockerfile 0.34% Shell 0.27%

tvseriesrenamer's People

Contributors

baldurk avatar fwenzel avatar meermanr avatar zed0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tvseriesrenamer's Issues

Unsuccessful run leaves .URL junk file behind

STR:

[~]$ mkdir /tmp/foo

[~]$ cd /tmp/foo

[/tmp/foo]$ tvrenamer.pl 
TV Series Renamer v2.56
Released 24 April 2012
Autodetecting season number failed
Detected series name 'foo' (Season 1 (assumed))
Reading input in AutoFetch mode from EpGuides.com
Fetching document ... 
Can't fetch "http://epguides.com/foo/", please check this URL in a browser
 Consider specifying an URL on the command-line. Error was: 
No useable results. Trying: TV.com
Performing search...
Match = season-1/Found match!
Creating link file in current directory to avoid repeating search...
Unsupported input source: "season-1/"%

[/tmp/foo]$ ls -l
total 8
-rw-r--r--  1 fred  wheel  33 Jan 23 09:24 foo (Season 1) [TV.com].URL

[/tmp/foo]$ 

Quote Characters From ".tvrenamerrc" Are Not Ignored

I use following scheme to clean up my files: tvrenamer.pl --scheme=SXXEYY --pad=2 --include-series --separator=" " which ends up with file names like Series Title S00E00 A Title.suffix. This works well.

To automatise this I created a ".tvrenamerrc":

$ cat ~/.tvrenamerrc 
--scheme=SXXEYY
--pad=2
--include-series
--separator=" "

But now the file names end up like Series Title S00E00" "A Title.suffix, which is not what I would expect to happen.

Changing ".tvrenamerrc" to:

$ cat ~/.tvrenamerrc 
--scheme=SXXEYY
--pad=2
--include-series
--separator= 

works around the problem. The line with --separator= ends with a (invisible) space (which makes the file somewhat hard to maintain as one needs to be aware of the kludge.) I think the config file parser should ignore quotes in such cases for consistency with the command line handling.

UTF-8 issues

Common episode titles only very rarely use UTF-8, but anyway: tvrenamer does not handle UTF-8 right. Instead of handling a multi-byte character as a single character, it interprets the string as ASCII and misnames the files.

Some test cases would be:
http://epguides.com/Stromberg/ -> season 1, episode 7 has an o-umlaut
http://epguides.com/City/ -> season 1, episode 22 has a utf-8 ellipsis

Considering epguides correctly identifies its pages as being utf-8, the script should probably handle them as such too.

Hope this isn't too hard to fix. (We both know in Python it wouldn't be ;) )

Episode Titles Fetched from "epguide.com" Sometimes Contain Junk

I usually fetch titles via "epguide.com". In some cases the resulting filenames contain superfluous extra junk that is not filtered properly (or could/should be filtered).

E.g. Episodes of season 1 and 2 of http://epguides.com/realhusbandsofhollywood/ have some "(60 min)" marker at the end which is not properly stripped and ends up as Series Title S00E00 Episode Title--a- (60 min).suffix.

Another problem that I sometimes notice is that & ends up as part of the episode title in the filenames rather than just &, e.g. Series S00E00 Foo & Bar.suffix.

Decode HTML encoding in names

From #21:

Another problem that I sometimes notice is that & ends up as part of the episode title in the filenames rather than just &, e.g. Series S00E00 Foo & Bar.suffix.
Just for completeness an example for the & issue: it would happen with episode 13 of season 26 of http://epguides.com/Simpsons/, the file name becomes like The Simpsons S26E14 Walking Big & Tall.mp4.

Script is not compatible with Perl v5.8.8

tvrenamer.pl v2.53
perl v5.8.8

$ ~/tmp/tvrenamer.pl --help
Sequence (?P...) not recognized in regex; marked by <-- HERE in m/^(?P <-- HERE <prefix>.*)(?:season|series)\s*(?P<season>\d+)\s*$/ at /home/samba/tmp/tvrenamer.pl line 374.


Line 374,375 look like this:

   if( $series =~ m{^(?P<prefix>.*)(?:season|series)\s*(?P<season>\d+)\s*$}i
           or $series =~ m{^\s*(?P<season>\d+)\s*$}i ){

Clean up tests dir and test runner?

Can I clean up run.py and make it look pythonic? If so, I'll submit a pull request :)

I am quite impressed how well the script works so I am happy to help a bit keeping the test suite look nice and shiny.

Let me know!

Modification of a read-only value attempted at tvrenamer.pl line 1750.

Error: Modification of a read-only value attempted at tvrenamer.pl line 1750.

Execution Output - Perl Warnings and Error

user@computer:/mnt/data/Series/ShowName$ perl -W ~/tvrenamer.pl
Illegal hexadecimal digit '|' ignored at /home/user/tvrenamer.pl line 519.
Illegal hexadecimal digit '|' ignored at /home/user/tvrenamer.pl line 519.
Illegal hexadecimal digit '|' ignored at /home/user/tvrenamer.pl line 530.
Illegal hexadecimal digit '|' ignored at /home/user/tvrenamer.pl line 530.
\1 better written as $1 at /home/user/tvrenamer.pl line 664.
\1 better written as $1 at /home/user/tvrenamer.pl line 665.
Illegal hexadecimal digit '|' ignored at /home/user/tvrenamer.pl line 751.
Illegal hexadecimal digit '|' ignored at /home/user/tvrenamer.pl line 751.
\1 better written as $1 at /home/user/tvrenamer.pl line 841.
"my" variable $i masks earlier declaration in same scope at /home/user/tvrenamer.pl line 1207.
"my" variable $i masks earlier declaration in same scope at /home/user/tvrenamer.pl line 1209.
Illegal hexadecimal digit '|' ignored at /home/user/tvrenamer.pl line 1461.
Illegal hexadecimal digit '|' ignored at /home/user/tvrenamer.pl line 1461.
Scalar value @first[...] better written as $first[...] at /home/user/tvrenamer.pl line 1397.
Scalar value @second[...] better written as $second[...] at /home/user/tvrenamer.pl line 1397.
Name "Encode::Locale::ENCODING_UTF-8" used only once: possible typo at /usr/share/perl5/Encode/Locale.pm line 106.
TV Series Renamer v2.56
Released 24 April 2012
Use of uninitialized value $ENV{"USERPROFILE"} in concatenation (.) or string at /home/user/tvrenamer.pl line 287.
Use of uninitialized value $ENV{"USERPROFILE"} in concatenation (.) or string at /home/user/tvrenamer.pl line 288.
Reading preferences from /home/user/.tvrenamerrc
Autodetecting season number failed
Use of uninitialized value $inputFile in string eq at /home/user/tvrenamer.pl line 601.
Detected series name 'ShowName' (Season 1 (assumed))
Reading input in AutoFetch mode from EpGuides.com
Input is URL: http://epguides.com/Dexter/
Checking freshness of .cache...
Cache is 0.0159490740740741 days old. (15min = 0.0104166666666667)
could be fresher
Fetching document http://epguides.com/ShowName/... [Done]
Use of uninitialized value $epTitle in substitution (s///) at /home/user/tvrenamer.pl line 1063.
Use of uninitialized value $data in substitution (s///) at /home/user/tvrenamer.pl line 1740.
Use of uninitialized value $data in substitution (s///) at /home/user/tvrenamer.pl line 1741.
Use of uninitialized value $epTitle in substitution (s///) at /home/user/tvrenamer.pl line 1063.
Use of uninitialized value $data in substitution (s///) at /home/user/tvrenamer.pl line 1740.
Use of uninitialized value $data in substitution (s///) at /home/user/tvrenamer.pl line 1741.
Modification of a read-only value attempted at /home/user/tvrenamer.pl line 1750.

* Name of show substituted to generic ShowName

Source Code - tvrenamer.pl - v2.56

nl -b a ~/tvrenamer.pl | sed -n 1746,1761p
  1746  sub clean_up #{{{
  1747  {
  1748  # Prepare arguments for filesystem, and do some tidying
  1749          foreach(@_){
  1750                  tr/\\/-/;                                       # Replace invalid char \ with -
  1751                  tr/\//-/;                                       # Replace invalid char / with -
  1752                  tr/\*/-/;                                       # Replace invalid char * with -
  1753                  tr/\</-/;                                       # Replace invalid char < with (
  1754                  tr/\>/-/;                                       # Replace invalid char > with )
  1755                  tr/\:/-/;                                       # Replace invalid char : with -
  1756                  tr/\x60/\x27/;                          # Replace ` with ' (Using ANSI char vals in _hex_)
  1757                  tr/\x22/\x27/;                          # Replace " with '
  1758                  tr/\x3F//d;                                     # Delete invalid char '?'
  1759          }
  1760          return @_;
  1761  } #}}} End sub

Perl Version

perl --version
This is perl 5, version 20, subversion 1 (v5.20.1) built for i686-linux-gnu-thread-multi-64int

Reference To Cause of Error = @_

http://www.perlmonks.org/?node_id=570712#param_lvalue
Common Causes for "Modification of a read-only value attempted"

Modifying elements of @_ directly

Perl Docs Regarding @_ Variable

http://perldoc.perl.org/perlvar.html#General-Variables
@_

Within a subroutine the array @_ contains the parameters passed to that subroutine. Inside a subroutine, @_ is the default array for the array operators push, pop, shift, and unshift.
See perlsub.

http://perldoc.perl.org/perlsub.html

Because the assignment copies the values, this also has the effect of turning call-by-reference into call-by-value. Otherwise a function is free to do in-place modifications of @_ and change its caller's values.

    upcase_in($v1, $v2); # this changes $v1 and $v2
    sub upcase_in {
    for (@_) { tr/a-z/A-Z/ }
    }

You aren't allowed to modify constants in this way, of course. If an argument were actually literal and you tried to change it, you'd take a (presumably fatal) exception. For example, this won't work:

Typo

Search for "not renmaing either!" (sic) in the .pl file.

EpGuides.com format has changed.

TV Series Renamer v2.56
Released 24 April 2012
Detected series name 'Homeland' (Season 7)
Reading input in AutoFetch mode from EpGuides.com
Input is URL: http://epguides.com/Homeland/
Will not look for cache file
Fetching document http://epguides.com/Homeland/... [Done]
No useable results. Trying: TV.com
Search URL: http://www.tv.com/index.php?type=Search&stype=ajax_search&qs=Homelan
d&search_type=program&pg_results=0&sort=
Performing search...
Problem with server (received 0 bytes)...
Performing search...
Problem with server (received 0 bytes)...
Performing search...
Problem with server (received 0 bytes)...
Unable to perform search on TV.com! (Fetched bytes of data) Please try the foll
owing in a browser:
http://www.tv.com/index.php?type=Search&stype=ajax_search&qs=Homeland&search_t
ype=program&pg_results=0&sort=
at /cygdrive/c/bin/tvrenamer.pl line 693.

Commit 22f4cf7 breaks "Thundercats 2011"

(Originally reported by KlfJoat in his comment on commit 22f4cf7)

The change on line 668 is bad. This breaks such things as "Thundercats 2011". The URL on epguides.com is "Thundercats_2011". So if I specify --series="Thundercats_2011", this regex changes the underscore to a space, making the episode names unfindable on epguides.com. (it's also unfindable on tv.com, which this fix is supposed to help with)

Ignore dot files

Regardless of how they get there (I am looking at you, OS X), the script should probably ignore dotfiles.

I have these files, for example:

._12 - Awesome Episode.mp4
12 - Awesome Episode.mp4

The former is OS X's doing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.