first commit: pt.js, insert_chapters.pl
This commit is contained in:
parent
75e58c8fab
commit
7b5f8ff109
|
@ -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 <pc-ts>-tags in a HTML-Page to links.
|
||||
|
|
37
insert_chapters/insert_chapters.pl
Executable file
37
insert_chapters/insert_chapters.pl
Executable file
|
@ -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 <<EOF;
|
||||
Usage: $0 -h | chapters-file [ogg-file]
|
||||
EOF
|
||||
}
|
||||
|
||||
open (my $f, '<', $ARGV[0]) or die "Can't open file [$ARGV[0]]: $@";
|
||||
while (<$f>) {
|
||||
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;
|
||||
}
|
5
pt/Makefile
Normal file
5
pt/Makefile
Normal file
|
@ -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 $<
|
50
pt/pt.coffee
Normal file
50
pt/pt.coffee
Normal file
|
@ -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()
|
||||
$ '<a>'
|
||||
.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)
|
Loading…
Reference in a new issue