2008-09-09 07:52:08 PDT
I'm not sure if this is the best place for this but, I couldn't get one of the scripts to work on the site wiki for sorting Video files by name/season/episode so I altered the code slightly if anyone was having problems getting it to work. Basically I added a couple of regex for checking other patterns in the title name as well as preserved case. I alos could not for the life of me find out what |>, meant (I'm assuming it was just a join of some sort for the next line but it kept erroring on me).
Anyway ... I created a single file with the original against my changes and just made a patch of that so if you want the changes either manually put them in, or create a new file with the code on the site and patch it using the patch file :)
--- import.2.js 2008-09-09 08:25:41.000000000 -0600
+++ import.1.js 2008-09-09 08:24:01.000000000 -0600
@@ -2,11 +2,15 @@
{
var excludeSamples = true;
var fixEpisodeNames = true;
-
- var patterns = [ /(.*)s(\d\d)e(\d\d)(\D.*)/i|>,
- /(.*)s(\d\d)(\D)(.*)/i|>,
- /(\D*)[\.|\-|_](\d)(\d\d)([\.|\-|_]\D.*)/i|>,
- /(\D*)(\d)[^0-9](\d\d)(\D.*)/i|> ];
+
+ var patterns = [ /(.*)s(\d\d)e(\d\d)(\D.*)/i,
+ /(.*)s(\d)e(\d\d)(\D.*)/i,
+ /(.*)s(\d)e(\d)(\D.*)/i,
+ /(.*|_*|-*)s(\d\d)e(\d\d)(\D.*)/i,
+ /(.*)s(\d\d)(\D)(.*)/i,
+ /(\D*)[\.|\-|_](\d)(\d\d)([\.|\-|_]\D.*)/i,
+ /(\D*)(\d)[^0-9](\d\d)(\D.*)/i ];
+
for(var i=0;i<patterns.length;i++){
var match = patterns[i].exec(obj.title);
if(match){
@@ -29,7 +33,7 @@
leftover = obj.title;
}
- var chain = new Array('Video', 'TV Shows');
+ var chain = new Array('Videos', 'Sorted TV Shows');
chain.push(name);
var paddedSeason = 'Season ' + padLeft(season, '0', 2);
chain.push(paddedSeason);
@@ -77,7 +81,7 @@
name = removeStartingDashesAndSpaces(name);
name = removeEndingDashesAndSpaces(name);
- return toProperCase(name);
+ return name;
}
function removeStartingDashesAndSpaces(name){
if(name.length == 0)
@@ -99,12 +103,7 @@
}
return name;
}
-function toProperCase(s)
-{
- return s.toLowerCase().replace(/^(.)|\s(.)/g|>,
- function($1) { return $1.toUpperCase(); });
-}
-
+
function padLeft(str, pad, count) {
str += '';
while(str.length < count){
regards,
Lonny