[Python] Corrie TV (Coronation Street)/Enders renamer script

Come up with a useful post-processing script? Share it here!
jamesjfa
Jr. Member
Jr. Member
Posts: 50
Joined: June 15th, 2012, 9:37 pm

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by jamesjfa »

Hi J03 8LACK I'm back.....

With the recent closure of nzbmarix I am back to using binsearch. Have also tried to setup my own newznab server but having trouble with the regex on the a.b.british.drama newsgroup. Pulls in all the parts but will not make it into a release.

Anyway good to see you are still helping out. It was you that got all this going for me. So again.... a big thank you.

PS still crc errors etc with binsearch. just grabbing them manually.
J03 8LACK
Full Member
Full Member
Posts: 120
Joined: April 2nd, 2009, 1:33 am

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by J03 8LACK »

jamesjfa wrote: PS still crc errors etc with binsearch. just grabbing them manually.
jamesifa,

I got around crc errors by increasing the RSS Checking Interval to 360

give it a try and tell me how it works out.

J03
jamesjfa
Jr. Member
Jr. Member
Posts: 50
Joined: June 15th, 2012, 9:37 pm

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by jamesjfa »

Will Change that now.

Will come back and let you know. I've noticed Eastenders is now failing to rename. Have you had a look at that recently?

Cheers,
James
bragg2012
Newbie
Newbie
Posts: 5
Joined: April 9th, 2010, 4:27 am

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by bragg2012 »

Hello,

Any chance you can filter so it only pulls the HD versions of the show?
J03 8LACK
Full Member
Full Member
Posts: 120
Joined: April 2nd, 2009, 1:33 am

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by J03 8LACK »

jamesjfa wrote: I've noticed Eastenders is now failing to rename. Have you had a look at that recently?
Hey Jamesjfa,

The Eastenders is now being up loaded by teevee and its being labeled correctly (SxxExx) so the script is not needed.
Can you check if Sickbeard can find it, If not you can use Sabnzbd+ to find it and drop the NZB in the Tv watch folder to be processed by Sickbeard.

Hope it works for you.

and bragg2012,
bragg2012 wrote: Any chance you can filter so it only pulls the HD versions of the show?
If you can find someone who is uploading the latest episodes in HD version then I can filter but only SD is being uploaded.

have great one
J03
bragg2012
Newbie
Newbie
Posts: 5
Joined: April 9th, 2010, 4:27 am

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by bragg2012 »

Hi J03,

I'm currently getting the same error as Phreaq:

"Exit(1) All files failed renaming please check Failed folder" and in the log "All files failed renaming please check Failed folder" so it looks like it's bombing out at:

Code: Select all

if len(goodname) > 2:    # checks if all files failed renaming
         goodcount = goodcount + 1
      os.rename(filename, goodname)
   else :
      print "not an avi deleting file"
      os.remove(name)
if goodcount == 0:
   sys.exit('All files failed renaming please check Failed folder')
if badcount > 0:
   print 'Some files caused errors and have been moved to your Failed Folder'
- There's nothing in the failed folder but in the temp folder remains the .avi and the .nzb which doesn't look like its been renamed in any way.

Any help greatly appreciated.

(on another note I did have a little bother getting the script up and running and had to also add ;c:\Python27 to the PATH variable as per the instructions here - in case anyone else has the same problem)
J03 8LACK
Full Member
Full Member
Posts: 120
Joined: April 2nd, 2009, 1:33 am

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by J03 8LACK »

bragg2012 wrote:Hi J03,

I'm currently getting the same error as Phreaq:

"Exit(1) All files failed renaming please check Failed folder" and in the log "All files failed renaming please check Failed folder" so it looks like it's bombing out at:

Code: Select all

if len(goodname) > 2:    # checks if all files failed renaming
         goodcount = goodcount + 1
      os.rename(filename, goodname)
   else :
      print "not an avi deleting file"
      os.remove(name)
if goodcount == 0:
   sys.exit('All files failed renaming please check Failed folder')
if badcount > 0:
   print 'Some files caused errors and have been moved to your Failed Folder'
- There's nothing in the failed folder but in the temp folder remains the .avi and the .nzb which doesn't look like its been renamed in any way.

Any help greatly appreciated.

(on another note I did have a little bother getting the script up and running and had to also add ;c:\Python27 to the PATH variable as per the instructions here - in case anyone else has the same problem)
Hey Braqq2012,

Can you post the full log with the error?

I'm seeing no problems with the code on my end double check your settings and post the error log in sabnzbd.
The error your getting would mean that there is no .avi's in your (yourPath folder which is defined by you at the top of the Script).

J03
bragg2012
Newbie
Newbie
Posts: 5
Joined: April 9th, 2010, 4:27 am

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by bragg2012 »

J03 8LACK wrote:
bragg2012 wrote:Hi J03,

I'm currently getting the same error as Phreaq:

"Exit(1) All files failed renaming please check Failed folder" and in the log "All files failed renaming please check Failed folder" so it looks like it's bombing out at:

Code: Select all

if len(goodname) > 2:    # checks if all files failed renaming
         goodcount = goodcount + 1
      os.rename(filename, goodname)
   else :
      print "not an avi deleting file"
      os.remove(name)
if goodcount == 0:
   sys.exit('All files failed renaming please check Failed folder')
if badcount > 0:
   print 'Some files caused errors and have been moved to your Failed Folder'
- There's nothing in the failed folder but in the temp folder remains the .avi and the .nzb which doesn't look like its been renamed in any way.

Any help greatly appreciated.

(on another note I did have a little bother getting the script up and running and had to also add ;c:\Python27 to the PATH variable as per the instructions here - in case anyone else has the same problem)
Hey Braqq2012,

Can you post the full log with the error?

I'm seeing no problems with the code on my end double check your settings and post the error log in sabnzbd.
The error your getting would mean that there is no .avi's in your (yourPath folder which is defined by you at the top of the Script).

J03
The only thing that appears in the sab log is "All files failed renaming please check Failed folder" - I'll double check my paths tonight and report back.
jamesjfa
Jr. Member
Jr. Member
Posts: 50
Joined: June 15th, 2012, 9:37 pm

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by jamesjfa »

The ones uploaded on teevee were great no renaming. unfortunately they come out infrequently. Another poster has been adding them to a.b.british.drama (which I eventually got a working regex with Newznab. Corrie & Eastenders) )in 2 different name formats. They are

For USA: EastEnders 20121231

and today's is

EastEnders 20130101

However none of these process without the script or with the script.

Are you able to do your magic with the script?

Cheers,
James
J03 8LACK
Full Member
Full Member
Posts: 120
Joined: April 2nd, 2009, 1:33 am

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by J03 8LACK »

jamesjfa wrote:The ones uploaded on teevee were great no renaming. unfortunately they come out infrequently. Another poster has been adding them to a.b.british.drama (which I eventually got a working regex with Newznab. Corrie & Eastenders) )in 2 different name formats. They are

For USA: EastEnders 20121231

and today's is

EastEnders 20130101

However none of these process without the script or with the script.

Are you able to do your magic with the script?

Cheers,
James
Happy NewYears James,

Here is a script that should work with the new naming format - setup is the same

http://www.mediafire.com/?8m78s94syww8jha

Hows everything else working for you? newznab? corrie script?
report back if everything is in working order.

J03
Last edited by J03 8LACK on January 9th, 2013, 2:06 am, edited 2 times in total.
jamesjfa
Jr. Member
Jr. Member
Posts: 50
Joined: June 15th, 2012, 9:37 pm

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by jamesjfa »

Happy New Year to you too J03.

Thank you I will import it tonight. The corrie script is still working well. After Matrix shutdown I decided to try my own with Newznab. No backfill just around 30 days old now. Seems to work ok. No issues with CRC errors like binsearch.

If you get time, would you be able to go through the script with me explaining what each section does? I would like to know more about it. At the top of the original eastenders one I have:

#!/usr/bin/env python

Should I add this to the top of the new one?

Cheers,
James
jamesjfa
Jr. Member
Jr. Member
Posts: 50
Joined: June 15th, 2012, 9:37 pm

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by jamesjfa »

Just applied the script and tried it on both files. Superb as always thank you.

Cheers,
James
jamesjfa
Jr. Member
Jr. Member
Posts: 50
Joined: June 15th, 2012, 9:37 pm

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by jamesjfa »

I have tried to make changes to the eastenders script as a 2 part episode came out. the episode has been named:

EastEnders20130104-01
&
EastEnders20130104-02

I added this after the first multipart:
if AirDate[-1] == "01" : # correct multi part Airdate and flag MultiPart
airdatePart = AirDate.replace("01","")
AirDate = airdatePart
multiPart = 0
print AirDate
if AirDate[-1] == "02" :
airdatePart = AirDate.replace("02","")
AirDate = airdatePart
multiPart = 1

so it now looks like the following:

for filename in glob.glob(os.path.join(yourPath, "*EastEnders *")):
name = filename
print name
nameoffile = os.path.basename(name)
print "Orginal filename : " + nameoffile
pathname = os.path.dirname(name)
renameparts = nameoffile.split(' ')
print renameparts[0] + " 0"
print renameparts[1] + " 1"
renamedate = renameparts[1]
newnameoffile = renameparts[0] + "." + renamedate[0:4] + "-" + renamedate[4:6] + "-" + renamedate[6:]
nameoffile = newnameoffile
print "new filename : " + nameoffile
parts = nameoffile.split('.') # gives you ["EastEnders","Airdate","name"]
AirDate = parts[1]
print AirDate
print AirDate[-1]
if AirDate[-1] == "a" : # correct multi part Airdate and flag MultiPart
airdatePart = AirDate.replace("a","")
AirDate = airdatePart
multiPart = 0
print AirDate
if AirDate[-1] == "b" :
airdatePart = AirDate.replace("b","")
AirDate = airdatePart
multiPart = 1

if AirDate[-1] == "01" : # correct multi part Airdate and flag MultiPart
airdatePart = AirDate.replace("01","")
AirDate = airdatePart
multiPart = 0
print AirDate
if AirDate[-1] == "02" :
airdatePart = AirDate.replace("02","")
AirDate = airdatePart
multiPart = 1

print AirDate
print parts[-1]
if parts[-1] == 'avi':
print "File is an avi OK to rename" # checks if it an avi or not #
goodname = ' '
failedname = ' '

However I receive an error when it tries to process any eastender file. The error is:

File "/Users/Plex/Documents/SAB-Scripts/EndersTVrenameFIXv1.py", line 52
airdatePart = AirDate.replace("01","")
^
IndentationError: expected an indented block

If you get time, could you help with this?

Cheers,
James
J03 8LACK
Full Member
Full Member
Posts: 120
Joined: April 2nd, 2009, 1:33 am

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by J03 8LACK »

Hey James,

I was wondering when the first multi part episode would be.

you where on the right track but you missed the " - ". you also have to watch the formatting (the indents)

Code: Select all

 (the change noted at the side)
if AirDate[-1] == "1" :                            # changing to 01 was correct but the [-1] is only a single value 1
     airdatePart = AirDate.replace("-01","") # changing to -01 to remove all of the part # from the date
     AirDate = airdatePart
     multiPart = 0
     print AirDate                                    # used to debug the results outputs the value to the log/screen
if AirDate[-1] == "2" :                           # changing to 01 was correct but the [-1] is only a single value 2
     airdatePart = AirDate.replace("-02","")  # changing to -02 to remove all of the part # from the date
     AirDate = airdatePart
     multiPart = 1
     print AirDate                                   # used to debug the results outputs the value to the log/screen
***Side note when posting code use the code box tool (just place the code inbetween code and /code ****

I have uploaded the new version here - http://www.mediafire.com/?8m78s94syww8jha

The indent problems are created when you are not using a correct text editor. Try notepad++ or if you want to learn more about Python try IDLE which i think comes with the python install. you can debug your code in IDLE.

As for learning more Python I bought one book QuickStart Python and read as much as i could online. Try downloading other peoples scripts and try reading through them. When you get stuck google the commands and keep reading.

For the string problem above take a look here - http://docs.python.org/2/tutorial/intro ... ml#strings

There is also a free video course at MIT try here - http://ocw.mit.edu/courses/electrical-e ... -lectures/

And there is also Codecademy - http://www.codecademy.com/tracks/python

I have left all the print statements in so you can follow the code in the view script log in sabnzbd history view or click the more text

hope this helps
If you gain something from this pass it on to others

J03
ps if you have any question about the code just ask.
Last edited by J03 8LACK on January 9th, 2013, 2:05 am, edited 1 time in total.
jamesjfa
Jr. Member
Jr. Member
Posts: 50
Joined: June 15th, 2012, 9:37 pm

Re: [Python] Corrie TV (Coronation Street)/Enders renamer sc

Post by jamesjfa »

Thank you for this. Sorry I have been away and just come back today. Thank you for the tips. I applied the new script and what's weird now is that both Corrie and Eastenders on a 2 part episode, fail on episode 1.

Both formats are the same for each 2 part file. for example:

EastEnders 20130104-01
EastEnders 20130104-02

Coronation Street 07.01.2013 - Part 1
Coronation Street 07.01.2013 - Part 2

Only episode 1 on both occasions fails to rename.

Orginal filename : EastEnders 20130104-01.avi
EastEnders 0
20130104-01.avi 1
new filename : EastEnders.2013-01-04-01.avi
2013-01-04-01
1
2013-04
File is an avi OK to rename
Unable to find correct episode from the orginal filename
will move to failed folder for manual renaming
/Volumes/Downloads/SoapFailed/EastEnders.2013-01-04-01.avi

Orginal filename : coronation.street.07.01.12.part.1.[ws.pdtv].avi
avi
File is an avi OK to rename
Unable to find correct episode from the orginal filename
will move to failed folder for manual renaming
/Volumes/Downloads/SoapFailed/coronation.street.07.01.12.part.1.[ws.pdtv].avi
Post Reply