added files
This commit is contained in:
parent
cc3428b6f2
commit
0f7a3ce177
34
scrapeArchive.py
Normal file
34
scrapeArchive.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import re
|
||||||
|
import urllib2
|
||||||
|
import json
|
||||||
|
|
||||||
|
def parseList(filePath):
|
||||||
|
f = open(filePath)
|
||||||
|
urlList = []
|
||||||
|
for l in f:
|
||||||
|
if l.startswith("<a"):
|
||||||
|
id = re.compile(r'details/(.*?)">').findall(l)
|
||||||
|
url = "http://archive.org/details/" + id[0]
|
||||||
|
urlList.append({'id': id, 'url': url})
|
||||||
|
f.close()
|
||||||
|
return urlList
|
||||||
|
|
||||||
|
def getOgvPath(page):
|
||||||
|
filename = re.compile(r'IAD\.ogv\ \=\ "(.*?)"').findall(page)
|
||||||
|
server = re.compile(r'IAD.meta\ \=\ \{"server"\:\"(.*?)"').findall(page)
|
||||||
|
itemno = re.compile(r'IAD.thumbs\ \=\ \["\/([0-9])\/').findall(page)
|
||||||
|
path = "http://%s/%s/items/%s" % (server[0], itemno[0], filename[0],)
|
||||||
|
return path
|
||||||
|
|
||||||
|
def do(filePath):
|
||||||
|
urls = parseList(filePath)
|
||||||
|
ogvs = []
|
||||||
|
for u in urls:
|
||||||
|
try:
|
||||||
|
page = urllib2.urlopen(u['url']).read()
|
||||||
|
ogvPath = getOgvPath(page)
|
||||||
|
id = u['id']
|
||||||
|
ogvs.append({'id': id, 'path': ogvPath})
|
||||||
|
except:
|
||||||
|
print u['url']
|
||||||
|
return ogvs
|
51
test.html
51
test.html
|
@ -4,7 +4,7 @@
|
||||||
<script type="text/javascript" src="jquery.js"></script>
|
<script type="text/javascript" src="jquery.js"></script>
|
||||||
<script type="text/javascript" src="vidList.js"></script>
|
<script type="text/javascript" src="vidList.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var VID_PATH = "file:///media/SanjBeirutHFS/9-11/";
|
var VID_PATH = "file:///media/SeaEXT/Television/9-11/";
|
||||||
var NETWORKS = ['abc', 'bbc', 'cbs', 'cnn', 'fox', 'nbc'];
|
var NETWORKS = ['abc', 'bbc', 'cbs', 'cnn', 'fox', 'nbc'];
|
||||||
var currentVideos = {};
|
var currentVideos = {};
|
||||||
var timeInterval = -1;
|
var timeInterval = -1;
|
||||||
|
@ -25,8 +25,8 @@ for (var i=0; i < VID_LIST.length; i++) {
|
||||||
'filename': filename,
|
'filename': filename,
|
||||||
'path': (VID_PATH + filename).replace("fox", "fox5"),
|
'path': (VID_PATH + filename).replace("fox", "fox5"),
|
||||||
'date': parseInt(date, 10),
|
'date': parseInt(date, 10),
|
||||||
'start_time': parseInt(start_time, 10),
|
'start_time': new Date(2001, 8, parseInt(date, 10), getTimeHour(parseInt(start_time, 10)), getTimeMinutes(parseInt(start_time, 10))),
|
||||||
'end_time': parseInt(end_time, 10),
|
'end_time': new Date(2001, 8, parseInt(date, 10), getTimeHour(parseInt(end_time, 10)), getTimeMinutes(parseInt(end_time, 10))),
|
||||||
'id': '#' + network
|
'id': '#' + network
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -36,10 +36,11 @@ function getVideosAtTime(d, t, channels) {
|
||||||
if (typeof channels == 'undefined') {
|
if (typeof channels == 'undefined') {
|
||||||
channels = NETWORKS;
|
channels = NETWORKS;
|
||||||
}
|
}
|
||||||
|
var time = new Date(2001, 8, parseInt(d, 10), getTimeHour(t), getTimeMinutes(t));
|
||||||
var ret = {};
|
var ret = {};
|
||||||
for (var c = 0; c < channels.length; c++) {
|
for (var c = 0; c < channels.length; c++) {
|
||||||
var channel = channels[c];
|
var channel = channels[c];
|
||||||
var v = getVideoAtTime(d, t, channel);
|
var v = getVideoAtTime(d, time, channel);
|
||||||
if (v) {
|
if (v) {
|
||||||
ret[channel] = v;
|
ret[channel] = v;
|
||||||
}
|
}
|
||||||
|
@ -88,33 +89,15 @@ function getTimeMinutes(time) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTime(startTime, currentTime, date) {
|
function getTime(startTime, currentTime, date) {
|
||||||
var seekTime = Math.floor(currentTime / 60);
|
var currTime = startTime.getTime() + (currentTime * 1000);
|
||||||
var currTime = startTime + seekTime;
|
return new Date(currTime);
|
||||||
if (getTimeMinutes(currTime) >= 60) {
|
|
||||||
currTime = currTime + 40;
|
|
||||||
}
|
|
||||||
var hr = getTimeHour(currTime) + '';
|
|
||||||
if (hr.length == 1) {
|
|
||||||
hr = '0' + hr;
|
|
||||||
}
|
|
||||||
if ((currTime + '').length == 2) {
|
|
||||||
hr = "00";
|
|
||||||
}
|
|
||||||
var minutes = getTimeMinutes(currTime);
|
|
||||||
if ((minutes + '').length == 1) {
|
|
||||||
minutes = '0' + minutes;
|
|
||||||
}
|
|
||||||
var seconds = parseInt(currentTime % 60);
|
|
||||||
if ((seconds + '').length == 1) {
|
|
||||||
seconds = '0' + seconds;
|
|
||||||
}
|
|
||||||
return date + "th Sept. " + hr + ":" + minutes + ":" + seconds;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$('#search').click(function() {
|
$('#search').click(function() {
|
||||||
var date = parseInt($('#date').val());
|
var date = parseInt($('#date').val());
|
||||||
var time = parseInt($('#time').val(), 10);
|
var time = parseInt($('#time').val(), 10);
|
||||||
|
var timeObj = new Date(2001, 8, date, getTimeHour(time), getTimeMinutes(time));
|
||||||
console.log(time);
|
console.log(time);
|
||||||
var videos = getVideosAtTime(date, time);
|
var videos = getVideosAtTime(date, time);
|
||||||
currentVideos = videos;
|
currentVideos = videos;
|
||||||
|
@ -124,7 +107,7 @@ $(function() {
|
||||||
var video = videos[v];
|
var video = videos[v];
|
||||||
var id = '#' + video.network;
|
var id = '#' + video.network;
|
||||||
var jq = $(id);
|
var jq = $(id);
|
||||||
var secondsToSeek = getSecs(time, video.start_time);
|
var secondsToSeek = Math.floor((timeObj.getTime() - video.start_time.getTime()) / 1000);
|
||||||
var currPath = jq.attr("src");
|
var currPath = jq.attr("src");
|
||||||
if (currPath != video.path) {
|
if (currPath != video.path) {
|
||||||
jq.attr("src", video.path);
|
jq.attr("src", video.path);
|
||||||
|
@ -167,6 +150,16 @@ $(function() {
|
||||||
clearInterval(timeInterval);
|
clearInterval(timeInterval);
|
||||||
$('.menu').remove();
|
$('.menu').remove();
|
||||||
});
|
});
|
||||||
|
$('#playAll').click(function() {
|
||||||
|
$('video').each(function() {
|
||||||
|
this.play();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#pauseAll').click(function() {
|
||||||
|
$('video').each(function() {
|
||||||
|
this.pause();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -187,11 +180,7 @@ var menuActions = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'pauseThis': function(v) {
|
'pauseThis': function(v) {
|
||||||
if ($(v.id).get(0).isPlaying) {
|
|
||||||
$(v.id).get(0).pause();
|
$(v.id).get(0).pause();
|
||||||
} else {
|
|
||||||
$(v.id).get(0).play();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
'pauseOthers': function(v) {
|
'pauseOthers': function(v) {
|
||||||
for (var c in currentVideos) {
|
for (var c in currentVideos) {
|
||||||
|
@ -283,6 +272,8 @@ John Resig's micro-templating: http://ejohn.org/blog/javascript-micro-templating
|
||||||
</select>
|
</select>
|
||||||
Time: <input id="time" />
|
Time: <input id="time" />
|
||||||
<button id="search">Get Videos</button>
|
<button id="search">Get Videos</button>
|
||||||
|
<button id="playAll">Play All</button>
|
||||||
|
<button id="pauseAll">Pause All</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="videos">
|
<div id="videos">
|
||||||
<div id="line1">
|
<div id="line1">
|
||||||
|
|
1
vidList.js
Normal file
1
vidList.js
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user