diff --git a/README.md b/README.md index 23d1d26..a9d383f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ -# netcaster-helper -Helper scripts for netcaster (podcaster) +pt +=== + +URI-based jump in netcast to a specific timestamp. +Javascript for transforming all -tags in a HTML-Page to links. diff --git a/insert_chapters/insert_chapters.pl b/insert_chapters/insert_chapters.pl new file mode 100755 index 0000000..673fb17 --- /dev/null +++ b/insert_chapters/insert_chapters.pl @@ -0,0 +1,37 @@ +#!/usr/bin/perl +use strict; +use warnings; + +my $i = -1; +my @args; + +if (!$ARGV[0] or '-h' eq $ARGV[0]) { + print STDERR <) { + chomp; + my ($ts, $line) = split (/\s/, $_, 2); + $ts = "0$ts" if $ts =~ /^\d:/; + $ts = "$ts.000" if $ts =~ /:\d\d$/; + $ts = "${ts}00" if $ts =~ /:\d\d\.\d$/; + $ts = "${ts}0" if $ts =~ /:\d\d\.\d\d$/; + my $fl = '- '; + if ($ts =~ /^\d\d:\d\d:\d\d\.\d\d\d$/) { + $i++; + $fl = ''; + push @args, sprintf ("CHAPTER%03d=%s", $i, $ts); + } + push @args, sprintf ("CHAPTER%03dNAME=%s%s", $i, $fl, $line) if '' eq $fl; +} +close ($f); + +if ($ARGV[1]) { + exec 'vorbiscomment', '-w', $ARGV[1], map {('-t', $_)} @args; +} +else { + print "$_\n" for @args; +} diff --git a/pt/Makefile b/pt/Makefile new file mode 100644 index 0000000..8879975 --- /dev/null +++ b/pt/Makefile @@ -0,0 +1,5 @@ +pt.min.js: pt.js + uglifyjs --compress --mangle --reserved '$$' --in-source-map pt.js.map --output $@ --source-map $@.map $< + +pt.js: pt.coffee + coffee --compile --map $< diff --git a/pt/pt.coffee b/pt/pt.coffee new file mode 100644 index 0000000..92974e7 --- /dev/null +++ b/pt/pt.coffee @@ -0,0 +1,50 @@ +(($) -> + timestr = (t) -> + digits = (x, n, c) -> + c = if c then c else '0' + x = '' + Math.floor( x) + x = c + x while n > x.length + x + "#{digits(t/3600,2,'0')}:#{digits((t/60)%60,2,'0')}:#{digits(t%60,2,'0')}" + + strtime = (t) -> + if t and t = t.match /^(\d?\d):(\d\d):(\d\d)$/ + 3600*Math.floor( t[1])+60*Math.floor( t[2])+Math.floor( t[3]) + + netcastscroll = (a = $('#netcast')) -> + if a.is( '*') and (t = location.hash.match( /^#(\d?\d:\d\d:\d\d)$/)) + a[0].currentTime = strtime t[1] + undefined + + $ -> + $(window).on 'hashchange', -> + a = $ '#netcast' + if a.is '*' + netcastscroll a + a[0].play() + undefined + netcastscroll() + + $('pc-ts').replaceWith -> + $this = $ this + ts = $this.text() + $ '' + .text ts + .attr + class: $this.attr( 'class'), + href: "\##{ts}", 'netcast-timestamp': strtime(ts) + + $('#netcast').on 'timeupdate', (e) -> + ts = @currentTime + cel = [-1] + for el in $ '[netcast-timestamp]' + el = $ el + pcts = parseInt el.attr( 'netcast-timestamp') + cel = [pcts, el] if cel[0] < pcts and pcts <= ts + if cel[1] and not cel[1].is( '.netcast-current') + $('.netcast-current[netcast-timestamp]').removeClass 'netcast-current' + cel[1].addClass 'netcast-current' + undefined + + undefined +)(jQuery)