[PP-Script] VideoSort - better video sorting

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
Post Reply
freem@n
Posts: 8
Joined: 11 Jul 2013, 22:11

Re: [PP-Script] VideoSort - better video sorting

Post by freem@n » 10 Dec 2013, 14:27

NZBGet always crashed on PostProcess execution when I have this SeriesFormat in VideoSort: %sn/Season %s/%dn
if I remove the Season folder it works, but I would love to have it organized like my already existing shows in Season folders...

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] VideoSort - better video sorting

Post by hugbug » 10 Dec 2013, 14:38

Is it with the latest testing NZBGet version?

cheepa
Posts: 34
Joined: 13 Dec 2013, 04:02

Re: [PP-Script] VideoSort - better video sorting

Post by cheepa » 13 Dec 2013, 22:23

Is there a way for VideoSort not to rename a file? For example South.Park.S17E07.HDTV.x264-DHD, i don't want that file name to be renamed.

thanks

bgoldie
Posts: 20
Joined: 12 Jan 2013, 19:23

Re: [PP-Script] VideoSort - better video sorting

Post by bgoldie » 14 Dec 2013, 02:05

cheepa wrote:Is there a way for VideoSort not to rename a file? For example South.Park.S17E07.HDTV.x264-DHD, i don't want that file name to be renamed.

thanks
You can use %fn for the original filename.

cheepa
Posts: 34
Joined: 13 Dec 2013, 04:02

Re: [PP-Script] VideoSort - better video sorting

Post by cheepa » 14 Dec 2013, 02:44

bgoldie wrote:
cheepa wrote:Is there a way for VideoSort not to rename a file? For example South.Park.S17E07.HDTV.x264-DHD, i don't want that file name to be renamed.

thanks
You can use %fn for the original filename.
thanks bgoldie that worked.

minamhere
Posts: 4
Joined: 02 Dec 2013, 04:08

Re: [PP-Script] VideoSort - better video sorting

Post by minamhere » 26 Dec 2013, 04:44

I am trying to create a post processing script that will run after VideoSort. I want to copy the resulting file to a secondary location.

Is there a way to determine the final filename (or final path) after VideoSort renames and moves it? I know I can get FINALDIR, but I can't figure out how to get the final filename.

minimeh
Posts: 33
Joined: 16 Aug 2013, 09:54

Re: [PP-Script] VideoSort - better video sorting

Post by minimeh » 26 Dec 2013, 20:41

minamhere wrote:I am trying to create a post processing script that will run after VideoSort. I want to copy the resulting file to a secondary location.

Is there a way to determine the final filename (or final path) after VideoSort renames and moves it? I know I can get FINALDIR, but I can't figure out how to get the final filename.
I encountered a similar need to get the final filenames. My solution was to patch VideoSort.py. In the latest version of VideoSort.py, I replace (starting at line 1052):

Code: Select all

# Inform NZBGet about new destination path
finaldir = ''
uniquedirs = []
for filename in moved_dst_files:
	dir = os.path.dirname(filename)
	if dir not in uniquedirs:
		uniquedirs.append(dir)
		finaldir += '|' if finaldir != '' else ''
		finaldir += dir

if finaldir != '':
	print('[NZB] FINALDIR=%s' % finaldir)
with

Code: Select all

# Inform NZBGet about new destination path
finaldir = ''
uniquedirs = []
unique_names = set()

for filename in moved_dst_files:
	dir = os.path.dirname(filename)
	if dir not in uniquedirs:
		uniquedirs.append(dir)
		finaldir += '|' if finaldir != '' else ''
		finaldir += dir
		# Strip off the extension
		path = os.path.splitext(filename)[0]
		# Add the base name to the set. This is a no-op if the base name already exists
		unique_names.add(os.path.split(path)[1])

finalnames = ''
for filename in unique_names:
	if len(finalnames) == 0:
		finalnames = filename
	else:
		finalnames += "|%s" % filename    

if finaldir != '':
	print('[NZB] FINALDIR=%s' % finaldir)
if len(finalnames) > 0:
	print('[NZB] NZBPR_FINALENAMES=%s' % finalnames)
Notice that this collects the final filenames minus the extension. That way, I can readily find the media file and its satellites such as subtitles files.

In my pp script that uses the final filenames, I have something like this

Code: Select all

	finaldirectory = os.environ.get('NZBPP_FINALDIR', '')
	if len(finaldirectory) == 0:
		print('[INFO] No final directories passed to this post process script.')
		sys.exit(POSTPROCESS_NONE)
	finaldirectories = finaldirectory.split('|')

	finalname = os.environ.get('NZBPR_FINALENAMES', '')
	if len(finalname) == 0:
		print('[INFO] No final file names passed to this post process script.')
		sys.exit(POSTPROCESS_NONE)
	finalnames = finalname.split('|')
	for finaldirectory in finaldirectories:
		if DEBUG:
			print "finaldirectory = \"%s\"" % finaldirectory
		if os.path.exists(finaldirectory):
			for finalname in finalnames:
				if DEBUG:
					print "finalname = \"%s\"" % finalname
Whenever a new VideoSort.py is released, I use a merge tool to patch it. Not ideal, but it works for me.

minamhere
Posts: 4
Joined: 02 Dec 2013, 04:08

Re: [PP-Script] VideoSort - better video sorting

Post by minamhere » 27 Dec 2013, 18:15

minimeh,

Thanks. That was exactly what I needed!

I used glob.glob to get the file and any satellite files and then copy them to the second location. Works perfectly.

oofti
Posts: 6
Joined: 17 Jan 2014, 09:51

Re: [PP-Script] VideoSort - better video sorting

Post by oofti » 17 Jan 2014, 10:21

Hi all,

Managed to get Videosort installed on my Synology NAS where I have NZBGet running.

Couple of questions please:

1) Can I turn off naming for TV shows/series - I already perform this function in Sickbeard.
2) How would I configure for movies? I want the file name to equal the folder name and keep the movie file extension and any included .sub/.idx files (any nfo,nzb,html files should be removed)

Thanks in advance,

oofti

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] VideoSort - better video sorting

Post by hugbug » 17 Jan 2014, 10:53

oofti wrote:1) Can I turn off naming for TV shows/series - I already perform this function in Sickbeard.
Use a separate category for Sickbeard and don't use VideoSort for that category (setup option CategoryX.DefScript, you need to choose at least one script to override global option DefScript if you selected VideoSort in global DefScript).
Configure Sickbeard to use this category.
2) How would I configure for movies? I want the file name to equal the folder name and keep the movie file extension and any included .sub/.idx files (any nfo,nzb,html files should be removed)
That's in the options of VideoSort, please read option descriptions.

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests