From c693362cfe09148f59f800c166dec9d4ed357da6 Mon Sep 17 00:00:00 2001 From: stevenaw Date: Fri, 28 Jan 2011 15:36:26 -0500 Subject: [PATCH] Clean up parsers from base 0.3 branch --- parsers/parserSRT/data/data.srt | 35 -------- parsers/parserSRT/data/unit.srt | 11 --- parsers/parserSRT/popcorn.parserSRT.html | 41 ---------- parsers/parserSRT/popcorn.parserSRT.js | 62 -------------- parsers/parserSRT/popcorn.parserSRT.unit.html | 43 ---------- parsers/parserSRT/popcorn.parserSRT.unit.js | 42 ---------- parsers/parserVTT/data/data.vtt | 12 --- parsers/parserVTT/data/unit.vtt | 39 --------- parsers/parserVTT/popcorn.parserVTT.html | 41 ---------- parsers/parserVTT/popcorn.parserVTT.js | 82 ------------------- parsers/parserVTT/popcorn.parserVTT.unit.html | 44 ---------- parsers/parserVTT/popcorn.parserVTT.unit.js | 62 -------------- 12 files changed, 514 deletions(-) delete mode 100644 parsers/parserSRT/data/data.srt delete mode 100644 parsers/parserSRT/data/unit.srt delete mode 100644 parsers/parserSRT/popcorn.parserSRT.html delete mode 100644 parsers/parserSRT/popcorn.parserSRT.js delete mode 100644 parsers/parserSRT/popcorn.parserSRT.unit.html delete mode 100644 parsers/parserSRT/popcorn.parserSRT.unit.js delete mode 100644 parsers/parserVTT/data/data.vtt delete mode 100644 parsers/parserVTT/data/unit.vtt delete mode 100644 parsers/parserVTT/popcorn.parserVTT.html delete mode 100644 parsers/parserVTT/popcorn.parserVTT.js delete mode 100644 parsers/parserVTT/popcorn.parserVTT.unit.html delete mode 100644 parsers/parserVTT/popcorn.parserVTT.unit.js diff --git a/parsers/parserSRT/data/data.srt b/parsers/parserSRT/data/data.srt deleted file mode 100644 index defebc6..0000000 --- a/parsers/parserSRT/data/data.srt +++ /dev/null @@ -1,35 +0,0 @@ -1 -00:00:00,82 --> 00:00:03,09 -Hi, I am Po-Chiang (Bob), Po-Chiang Chao (Bob Chao) - -2 -00:00:03,14 --> 00:00:11,09 -I've participated in the project for about 6-7 years, starting from about 2002. - -3 -00:00:11,15 --> 00:00:17,17 -At first I started off translating technical documents and promoting web standards. - -4 -00:00:17,17 --> 00:00:21,90 -Since I am a web designer myself, I find it troublesome to have many different standards. - -5 -00:00:21,90 --> 00:00:24,61 -That's why I wanted to promote web standards. - -6 -00:00:24,78 --> 00:00:36,72 -The locale owner from two terms before, Lin Hong-De (piaip), invited me to help set up the moztw website, so I helped him. - -7 -00:00:36,72 --> 00:00:40,91 -After he entered the military service, I took over most of the works. Kind of like a lackey. - -8 -00:00:40,99 --> 00:00:47,64 -Up to now, the locale owner keeps changing, but I'm still helping out. - -9 -00:00:47,71 --> 99:59:59,00 -Mainly with marketing and promotion, and mostly to do with coordinating the community. diff --git a/parsers/parserSRT/data/unit.srt b/parsers/parserSRT/data/unit.srt deleted file mode 100644 index b88f84c..0000000 --- a/parsers/parserSRT/data/unit.srt +++ /dev/null @@ -1,11 +0,0 @@ -1 -00:00:02,400 --> 00:00:05,200 -[Background Music Playing] - -2 -00:00:15,712 --> 00:00:17,399 -Heay!! - -3 -00:00:25,712 --> 00:00:30,399 -[Bird noises] diff --git a/parsers/parserSRT/popcorn.parserSRT.html b/parsers/parserSRT/popcorn.parserSRT.html deleted file mode 100644 index 7f1f143..0000000 --- a/parsers/parserSRT/popcorn.parserSRT.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - Popcorn 0.3 SRT parser Plug-in Demo - - - - - - - -

Popcorn 0.3 SRT parser Plug-in Demo

-

-
- -
- - - - - diff --git a/parsers/parserSRT/popcorn.parserSRT.js b/parsers/parserSRT/popcorn.parserSRT.js deleted file mode 100644 index 6446f94..0000000 --- a/parsers/parserSRT/popcorn.parserSRT.js +++ /dev/null @@ -1,62 +0,0 @@ -// PARSER: 0.3 SRT - -(function (Popcorn) { - Popcorn.parser( "parseSRT", "SRT", function( data ) { - - // declare needed variables - var retObj = { - title: "", - remote: "", - data: [] - }, - subs = []; - - var toSeconds = function(t_in) { - var t = t_in.split(':'); - var time = 0; - - try { - var s = t[2].split(','); - - time += parseFloat(t[0], 10)*60*60; // hours => seconds - time += parseFloat(t[1], 10)*60; // minutes => seconds - time += parseFloat(s[0], 10); - time += parseFloat(s[1], 10)/1000; - } catch (e) { time = 0; } - - return time; - }; - - var createTrack = function( name, attributes ) { - var track = {}; - track[name] = attributes; - return track; - }; - - var lines = data.text.replace("\r",'').split("\n"); - - for(var i=0, l=lines.length; i "); - var text = ""; - - sub.start = toSeconds(time[0]); - sub.end = toSeconds(time[1]); - - while (lines[i] && lines[i] !== "\r") { - text += lines[i++].replace("\r", ""); - } - - sub.text = text; - - subs.push( createTrack("subtitle", sub) ); - } - - retObj.data = subs; - - return retObj; - }); - -})( Popcorn ); diff --git a/parsers/parserSRT/popcorn.parserSRT.unit.html b/parsers/parserSRT/popcorn.parserSRT.unit.html deleted file mode 100644 index 6f987c4..0000000 --- a/parsers/parserSRT/popcorn.parserSRT.unit.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - Popcorn 0.3 SRT parser Plug-in Test - - - - - - - - - - - -

Popcorn 0.3 SRT parser Plug-in Test

-

-
-

-
    -
    - - - - \ No newline at end of file diff --git a/parsers/parserSRT/popcorn.parserSRT.unit.js b/parsers/parserSRT/popcorn.parserSRT.unit.js deleted file mode 100644 index 80e56c3..0000000 --- a/parsers/parserSRT/popcorn.parserSRT.unit.js +++ /dev/null @@ -1,42 +0,0 @@ -test("Popcorn 0.3 SRT Parser Plugin", function () { - - var expects = 4, - count = 0, - key, - numSubs = 0, - poppercorn = Popcorn( "#video" ), - subs = { // Expected values - "2.4": "[Background Music Playing]", - "15.712": "Heay!!", - "25.712": "[Bird noises]" - }; - - function plus() { - if ( ++count === expects ) { - start(); - } - } - - poppercorn.parseSRT("data/unit.srt"); - - expect(expects); - - stop( 10000 ); - - // Allow load time - setTimeout(function () { - Popcorn.forEach(poppercorn.getTrackEvents(), function(evt) { - if(evt._natives.type === "subtitle") { - numSubs++; - key = evt.start.toString(); - equals(subs[key], evt.text , "Correct amounts" ); - plus(); - } - }); - - equals(3, numSubs , "Correctly parsed all subs" ); - plus(); - - }, 500); - -}); \ No newline at end of file diff --git a/parsers/parserVTT/data/data.vtt b/parsers/parserVTT/data/data.vtt deleted file mode 100644 index 58f9ec9..0000000 --- a/parsers/parserVTT/data/data.vtt +++ /dev/null @@ -1,12 +0,0 @@ -1 -00:00:02.400 --> 00:00:07.200 -Senator, we're making -our final approach into Coruscant. - -2 -00:00:09.712 --> 00:00:13.399 -Very good, Lieutenant. - -Track-3 -00:00:15.542 --> 00:00:18.542 A:start D:vertical L:98% -It's a trap! diff --git a/parsers/parserVTT/data/unit.vtt b/parsers/parserVTT/data/unit.vtt deleted file mode 100644 index 2d5a606..0000000 --- a/parsers/parserVTT/data/unit.vtt +++ /dev/null @@ -1,39 +0,0 @@ -1 -00:00:02.400 --> 00:00:07.200 -Senator, we're making -our final approach into Coruscant. - -2 -00:09.712-->00:13.399 -Very good, Lieutenant. - - - -3 -00:00:13.400 --> 00:00:20 -A bad cue, no milliseconds. Should be ignored - ---> -00:00:14.456--> 00:00:20.000 -A bad cue, bad id. Should be ignored - -4 -00:00:9.456--> 00:00:20.000 -A bad cue, seconds are single digit. Should be ignored - -5 -00:1:00.456--> 00:00:20.000 -A bad cue, minutes are single digit. Should be ignored - -6 -1:00:00.456--> 00:00:20.000 -A bad cue, hours are supplied as single digit. Should be ignored - -7 -00:00:00.46--> 00:00:20.000 -A bad cue, ms are not 3 digits. Should be ignored - -Track-3 -00:00:15.042 --> 00:00:18.042 A:start D:vertical L:98% -It's a trap! - diff --git a/parsers/parserVTT/popcorn.parserVTT.html b/parsers/parserVTT/popcorn.parserVTT.html deleted file mode 100644 index 99d55da..0000000 --- a/parsers/parserVTT/popcorn.parserVTT.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - Popcorn 0.3 VTT parser Plug-in Demo - - - - - - - -

    Popcorn 0.3 VTT parser Plug-in Demo

    -

    -
    - -
    - - - - - diff --git a/parsers/parserVTT/popcorn.parserVTT.js b/parsers/parserVTT/popcorn.parserVTT.js deleted file mode 100644 index cf0248a..0000000 --- a/parsers/parserVTT/popcorn.parserVTT.js +++ /dev/null @@ -1,82 +0,0 @@ -// PARSER: 0.3 VTT - -(function (Popcorn) { - Popcorn.parser( "parseVTT", "VTT", function( data ) { - - // declare needed variables - var retObj = { - title: "", - remote: "", - data: [] - }, - lines, time, text, sub, - subs = [], - i = 0, len = 0, idx = 0; - - // [HH:]MM:SS.mmm string to SS.mmm float - // Throws exception if invalid - var toSeconds = function(t_in) { - var t = t_in.split(':'); - var time, l = t_in.length; - - if (l !== 12 && l !== 9) throw "Bad cue"; - l = t.length - 1; - - try { - time = parseInt(t[l-1], 10)*60 + parseFloat(t[l], 10); - - if (l === 2) // Hours given - time += parseInt(t[0], 10)*60*60; // hours => seconds - } catch (e) { throw "Bad cue"; } - - return time; - }; - - var createTrack = function( name, attributes ) { - var track = {}; - track[name] = attributes; - return track; - }; - - // Here is where the magic happens - // Split on line breaks - lines = data.text.split(/(?:\r\n|\r|\n)/gm); - len = lines.length; - - while (i < len) { - sub = {}; - text = []; - - try { - sub.id = lines[i++]; - - if (!sub.id || sub.id.indexOf("-->") !== -1) throw "Bad cue"; - - time = lines[i++].split(/[\t ]*-->[\t ]*/); - - sub.start = toSeconds(time[0]); - - // Filter out any trailing styling info - idx = time[1].indexOf(" "); - sub.end = toSeconds(idx === -1 ? time[1] : time[1].substr(0, idx)); - - while (i < len && lines[i]) { - text.push(lines[i++]); - } - - sub.text = text.join(" "); - subs.push( createTrack("subtitle", sub) ); - } catch (e) { // Bad cue - while (i < len && lines[i++]); // Advance to end of cue - } - - // Consume empty whitespace - while (i < len && !lines[i]) { i++; } - } - - retObj.data = subs; - - return retObj; - }); - -})( Popcorn ); diff --git a/parsers/parserVTT/popcorn.parserVTT.unit.html b/parsers/parserVTT/popcorn.parserVTT.unit.html deleted file mode 100644 index a9b6683..0000000 --- a/parsers/parserVTT/popcorn.parserVTT.unit.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - Popcorn 0.3 VTT parser Plug-in Test - - - - - - - - - - - -

    Popcorn 0.3 VTT parser Plug-in Test

    -

    -
    -

    -
      -
      - - - - \ No newline at end of file diff --git a/parsers/parserVTT/popcorn.parserVTT.unit.js b/parsers/parserVTT/popcorn.parserVTT.unit.js deleted file mode 100644 index 77a639e..0000000 --- a/parsers/parserVTT/popcorn.parserVTT.unit.js +++ /dev/null @@ -1,62 +0,0 @@ -test("Popcorn 0.3 VTT Parser Plugin", function () { - - var count = 0, - numSubs = 0, - sub, - poppercorn = Popcorn( "#video" ), - subs = { // Expected values - "1": { - text: "Senator, we're making our final approach into Coruscant.", - start: 2.4, - end: 7.2 - }, - "2": { - text: "Very good, Lieutenant.", - start: 9.712, - end: 13.399 - }, - "Track-3": { - text: "It's a trap!", - start: 15.042, - end: 18.042 - } - }, - expectSubs = 3, - expects = expectSubs*4 + 1; - - function plus() { - if ( ++count === expects ) { - start(); - } - } - - poppercorn.parseVTT(document.getElementById('video').getAttribute('data-timeline-sources')); - - expect(expects); - - stop( 5000 ); - - // Allow load time - setTimeout(function () { - Popcorn.forEach(poppercorn.getTrackEvents(), function(evt) { - if(evt._natives.type === "subtitle") { - numSubs++; - sub = subs[evt.id.toString()]; - - ok(!!sub , "Correctly parsed id of " + evt.id ); - plus(); - equals(evt.text, sub.text, "Correctly parsed text of " + evt.id ); - plus(); - equals(evt.start, sub.start, "Correctly parsed start at " + evt.id ); - plus(); - equals(evt.end, sub.end, "Correctly parsed end at " + evt.id ); - plus(); - } - }); - - equals(expectSubs, numSubs , "Parsed all subs" ); - plus(); - - }, 500); - -}); \ No newline at end of file -- 2.43.0