Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
fix The Daily Show/The Colbert Report
Browse files Browse the repository at this point in the history
  • Loading branch information
chocolateboy committed Apr 5, 2014
1 parent 5ecaaa3 commit d9f83c6
Showing 1 changed file with 48 additions and 3 deletions.
51 changes: 48 additions & 3 deletions src/main/resources/scripts/youtube_dl_concat.groovy
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import groovyx.net.http.URIBuilder

// videofeed.Web,Comedy Central=http://extechops.net/full-episode-feeds/daily-show.rss
// videofeed.Web,Comedy Central=http://extechops.net/full-episode-feeds/colbert-report.rss

Expand All @@ -6,16 +8,59 @@ script (INIT) {
def FILENAME = 'pmsencoder_ffmpeg_concat_%d_%d.txt'
def TEMP_FOLDER = pms.getConfiguration().getTempFolder()

// XXX not sure if this is needed for the previously-used domains (without the .cc)
// or even if they're still used
profile ('Comedy Central: /episodes/ -> /full-episodes/', stopOnMatch: false) {
pattern {
// this is a workaround for a youtube-dl bug (or at least a missing feature)
match { YOUTUBE_DL_PATH }
domains([ 'thedailyshow.cc.com', 'thecolbertreport.cc.com' ])
}

/*
* XXX youtube-dl doesn't grok Comedy Central pages whose paths start with /episodes, but does handle
* those that start with /full-episodes, so replace the former with the latter:
*
* from: http://thedailyshow.com/episodes/wqf1x5/april-2--2014---samuel-l--jackson
* to: http://thedailyshow.com/full-episodes/wqf1x5/april-2--2014---samuel-l--jackson
*/
action {
/*
* XXX this would be much clearer/simpler if path was (also) exposed as a List e.g.:
*
* def u = new URIBuilder(uri)
*
* if (u.steps[0] == 'episodes') {
* u.steps[0] = 'full-episodes'
* uri = u.toString()
* }
*/
def u = new URIBuilder(uri)
def steps = u.path.split('/')

// path starts with a forward slash (and split preserves it), so steps is e.g.:
// [ '', 'episodes', 'wqf1x5', 'april-2--2014---samuel-l--jackson' ]
if (steps[1] == 'episodes') {
steps[1] = 'full-episodes'
u.path = steps.join('/')
uri = u.toString()
}
}
}

profile ('YouTube-DL Concat') {
pattern {
match { YOUTUBE_DL_PATH }
domains([ 'thedailyshow.com', 'colbertnation.com' ])
domains([ 'thedailyshow.com', 'thedailyshow.cc.com', 'colbertnation.com', 'thecolbertreport.cc.com' ])
}

action {
// doesn't use cmd.exe, so no need to quote the URI
// this command doesn't use cmd.exe, so no need to quote the URI
def command = YOUTUBE_DL_PATH + [ '-g', uri ]
def uris = command.execute().text.readLines(); logger.debug("URIs: ${uris.inspect()}")
def uris = command.execute().text.readLines()

logger.debug("URIs: ${uris.inspect()}")

def files = uris.collect({ "file '$it'" }).join(SEPARATOR)
def filename = String.format(FILENAME, Thread.currentThread().getId(), System.currentTimeMillis())
def file = new File(TEMP_FOLDER, filename); logger.trace("concat file: ${file.getAbsolutePath()}")
Expand Down

0 comments on commit d9f83c6

Please sign in to comment.