/* Title: Comskip Tester for SJQv4 Author: Derek Battams Modified By: Spectrum Last Updated: 06 Jan 2011 Use this groovy script as the test for your SJQv4 comskip tasks. This version of the script allows you to skip running comskip if: * The recording file extension does not match the first command line argument passed to this script * If an edl (or equivalent) already exists in the same directory as the recording * The recording channel is in a SkipList You can also configure this script to delay starting of comskip until the recording is completed. All of these settings are configured in the block below. Do not edit below the line specified unless you know what you're doing (and if you do then send me your bug fix patches, please). */ /*************** CONFIGURE VALUES IN THIS BLOCK ONLY! ***************/ boolean checkRecordingType = true; // Check the recording is of the type specified on the command line (i.e. only process mpg recordings) boolean checkForEdl = true; // If true, mark the task as skipped if an edl already exists String edlType = "edl"; // The edl extension (i.e. some people use .txt comskip files instead of .edl files) boolean comskipLive = true; // If false, this test will push the task back to the queue while the recording is in progress String SkipList = "STZ.*|WKOP.*|^MC.*|.*PPV.*"; // Regex of the channel names where comskip will not be performed /********************************************************************/ /************************* DO NOT EDIT BELOW!! **********************/ // But if you do edit below to fix a bug, then email me the patch! ;) int mfId = Integer.parseInt(SJQ4_METADATA.get("SJQ4_ID")); Object mf = MediaFileAPI.GetMediaFileForID(mfId); //String ChanName = SJQ4_METADATA.get("SJQ4_CHAN_NAME"); File path = new File(SJQ4_METADATA.get("SJQ4_PATH")); String fileName = SJQ4_METADATA.get("SJQ4_LAST_SEGMENT"); String fileType; if(SJQ4_ARGS.length > 0) fileType = SJQ4_ARGS[0]; else fileType = null; Object objAiring = MediaFileAPI.GetMediaFileAiring(mf); String ChanName = AiringAPI.GetAiringChannelName(objAiring); if(mfId > 0 && mf == null) { println("ERROR: Media file id provided, but object is null! It was probably deleted before this task started so marking task as SKIPPED!"); return 2; } if(mf == null || path == null || path.getAbsolutePath().length() == 0 || fileName == null || fileName.length() == 0) { println("ERROR: Invalid environment data passed to scritpt!"); return 1; } String edl = fileName.substring(0, fileName.lastIndexOf('.')) + "." + edlType; if(new File(path, edl).exists()) { println("An edl already exists for this recording, skipping comskip!"); println("Found '" + new File(path, edl).getAbsolutePath() + "'"); return 2; } if(checkRecordingType && fileType != null && fileType.length() > 0 && !fileName.endsWith("." + fileType)) { println("Recording is not of specified type '" + fileType + "', skipping comskip!"); return 2; } if(!comskipLive && MediaFileAPI.IsFileCurrentlyRecording(mf)) { println("Recording in progress, waiting..."); return 1; } // Skip if aired on channel without commercials or a channel with special needs :) if(ChanName ==~ SkipList){ println("Channel is in skip list, skipping comskip!"); return 2; } return 0;