forked from 0x2620/pandora
include oshash in video url to avoid cache issues
This commit is contained in:
parent
843cea063d
commit
3d6d1be2e6
7 changed files with 21 additions and 14 deletions
|
@ -126,10 +126,13 @@ class MetaClip(object):
|
||||||
j['cuts'] = tuple([c for c in self.item.get('cuts', []) if c > self.start and c < self.end])
|
j['cuts'] = tuple([c for c in self.item.get('cuts', []) if c > self.start and c < self.end])
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if key not in self.clip_keys and key not in j:
|
if key not in self.clip_keys and key not in j:
|
||||||
value = self.item.get(key) or self.item.json.get(key)
|
if key == 'streams':
|
||||||
|
value = [s.file.oshash for s in self.item.streams()]
|
||||||
|
else:
|
||||||
|
value = self.item.get(key) or self.item.json.get(key)
|
||||||
if not value and hasattr(self.item.sort, key):
|
if not value and hasattr(self.item.sort, key):
|
||||||
value = getattr(self.item.sort, key)
|
value = getattr(self.item.sort, key)
|
||||||
if value != None:
|
if value is not None:
|
||||||
j[key] = value
|
j[key] = value
|
||||||
return j
|
return j
|
||||||
|
|
||||||
|
@ -152,6 +155,7 @@ class MetaClip(object):
|
||||||
data['duration'] = data['out'] - data['in']
|
data['duration'] = data['out'] - data['in']
|
||||||
data['cuts'] = tuple([c for c in self.item.get('cuts', []) if c > self.start and c < self.end])
|
data['cuts'] = tuple([c for c in self.item.get('cuts', []) if c > self.start and c < self.end])
|
||||||
data['layers'] = self.get_layers(user)
|
data['layers'] = self.get_layers(user)
|
||||||
|
data['streams'] = [s.file.oshash for s in self.item.streams()]
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def get_layers(self, user=None):
|
def get_layers(self, user=None):
|
||||||
|
|
|
@ -149,7 +149,7 @@ def findClips(request, data):
|
||||||
if 'annotations' in keys:
|
if 'annotations' in keys:
|
||||||
aqs = Annotation.objects.filter(layer__in=settings.CONFIG['clipLayers'],
|
aqs = Annotation.objects.filter(layer__in=settings.CONFIG['clipLayers'],
|
||||||
clip__in=clips)
|
clip__in=clips)
|
||||||
add_annotations('annotations', aqs , True)
|
add_annotations('annotations', aqs, True)
|
||||||
|
|
||||||
for layer in filter(lambda l: l in keys, layer_ids):
|
for layer in filter(lambda l: l in keys, layer_ids):
|
||||||
aqs = Annotation.objects.filter(layer=layer, clip__in=clips)
|
aqs = Annotation.objects.filter(layer=layer, clip__in=clips)
|
||||||
|
|
|
@ -472,6 +472,8 @@ def get(request, data):
|
||||||
info = item.get_json(data['keys'])
|
info = item.get_json(data['keys'])
|
||||||
if not data['keys'] or 'stream' in data['keys']:
|
if not data['keys'] or 'stream' in data['keys']:
|
||||||
info['stream'] = item.get_stream()
|
info['stream'] = item.get_stream()
|
||||||
|
if not data['keys'] or 'streams' in data['keys']:
|
||||||
|
info['streams'] = [s.file.oshash for s in item.streams()]
|
||||||
if data['keys'] and 'layers' in data['keys']:
|
if data['keys'] and 'layers' in data['keys']:
|
||||||
info['layers'] = item.get_layers(request.user)
|
info['layers'] = item.get_layers(request.user)
|
||||||
if data['keys'] and 'documents' in data['keys']:
|
if data['keys'] and 'documents' in data['keys']:
|
||||||
|
|
|
@ -16,7 +16,7 @@ pandora.ui.item = function() {
|
||||||
'audioTracks',
|
'audioTracks',
|
||||||
'cuts', 'duration', 'durations', 'editable', 'layers',
|
'cuts', 'duration', 'durations', 'editable', 'layers',
|
||||||
'modified', 'parts', 'posterFrame', 'rendered', 'rightslevel',
|
'modified', 'parts', 'posterFrame', 'rendered', 'rightslevel',
|
||||||
'size', 'videoRatio',
|
'streams', 'size', 'videoRatio',
|
||||||
].concat(pandora.site.itemTitleKeys) : []
|
].concat(pandora.site.itemTitleKeys) : []
|
||||||
}, pandora.user.ui.itemView == 'info' && pandora.site.capabilities.canEditMetadata[pandora.user.level] ? 0 : -1, function(result) {
|
}, pandora.user.ui.itemView == 'info' && pandora.site.capabilities.canEditMetadata[pandora.user.level] ? 0 : -1, function(result) {
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ pandora.ui.itemClips = function(options) {
|
||||||
$img = $item.find('.OxIcon > img');
|
$img = $item.find('.OxIcon > img');
|
||||||
points = [$item.data('in'), $item.data('out')];
|
points = [$item.data('in'), $item.data('out')];
|
||||||
if ($img.length) {
|
if ($img.length) {
|
||||||
pandora.api.get({id: self.options.id, keys: ['durations', 'rightslevel']}, function(result) {
|
pandora.api.get({id: self.options.id, keys: ['durations', 'rightslevel', 'streams']}, function(result) {
|
||||||
var partsAndPoints = pandora.getVideoPartsAndPoints(
|
var partsAndPoints = pandora.getVideoPartsAndPoints(
|
||||||
result.data.durations, points
|
result.data.durations, points
|
||||||
),
|
),
|
||||||
|
@ -113,7 +113,8 @@ pandora.ui.itemClips = function(options) {
|
||||||
),
|
),
|
||||||
rewind: true,
|
rewind: true,
|
||||||
video: partsAndPoints.parts.map(function(i) {
|
video: partsAndPoints.parts.map(function(i) {
|
||||||
return pandora.getVideoURL(self.options.id, Ox.min(pandora.site.video.resolutions), i + 1);
|
return pandora.getVideoURL(self.options.id, Ox.min(pandora.site.video.resolutions), i + 1,
|
||||||
|
null, result.data.streams[i]);
|
||||||
}),
|
}),
|
||||||
width: self.width
|
width: self.width
|
||||||
})
|
})
|
||||||
|
|
|
@ -1021,7 +1021,7 @@ pandora.getClipVideos = function(clip, resolution) {
|
||||||
resolution = resolution || pandora.user.ui.videoResolution;
|
resolution = resolution || pandora.user.ui.videoResolution;
|
||||||
return Ox.flatten(Ox.range(clip.parts).map(function(i) {
|
return Ox.flatten(Ox.range(clip.parts).map(function(i) {
|
||||||
var item = {
|
var item = {
|
||||||
src: pandora.getVideoURL(clip.item, resolution, i + 1),
|
src: pandora.getVideoURL(clip.item, resolution, i + 1, null, clip.streams[i]),
|
||||||
resolution: resolution
|
resolution: resolution
|
||||||
};
|
};
|
||||||
if (currentTime + clip.durations[i] <= start || currentTime > end) {
|
if (currentTime + clip.durations[i] <= start || currentTime > end) {
|
||||||
|
@ -1937,12 +1937,12 @@ pandora.getMediaURL = function(url) {
|
||||||
return pandora.site.site.mediaprefix + url;
|
return pandora.site.site.mediaprefix + url;
|
||||||
};
|
};
|
||||||
|
|
||||||
pandora.getVideoURLName = function(id, resolution, part, track) {
|
pandora.getVideoURLName = function(id, resolution, part, track, streamId) {
|
||||||
return id + '/' + resolution + 'p' + part + (track ? '.' + track : '')
|
return id + '/' + resolution + 'p' + part + (track ? '.' + track : '')
|
||||||
+ '.' + pandora.user.videoFormat;
|
+ '.' + pandora.user.videoFormat + (streamId ? '?' + streamId : '');
|
||||||
};
|
};
|
||||||
|
|
||||||
pandora.getVideoURL = function(id, resolution, part, track) {
|
pandora.getVideoURL = function(id, resolution, part, track, streamId) {
|
||||||
var uid = Ox.uid(),
|
var uid = Ox.uid(),
|
||||||
prefix = pandora.site.site.videoprefix
|
prefix = pandora.site.site.videoprefix
|
||||||
.replace('{id}', id)
|
.replace('{id}', id)
|
||||||
|
@ -1952,7 +1952,7 @@ pandora.getVideoURL = function(id, resolution, part, track) {
|
||||||
.replace('{uid42}', uid % 42),
|
.replace('{uid42}', uid % 42),
|
||||||
local = pandora.fs && pandora.fs.getVideoURL(id, resolution, part, track);
|
local = pandora.fs && pandora.fs.getVideoURL(id, resolution, part, track);
|
||||||
return local || prefix + '/'
|
return local || prefix + '/'
|
||||||
+ pandora.getVideoURLName(id, resolution, part, track);
|
+ pandora.getVideoURLName(id, resolution, part, track, streamId);
|
||||||
};
|
};
|
||||||
|
|
||||||
pandora.getCensoredClips = function(data) {
|
pandora.getCensoredClips = function(data) {
|
||||||
|
@ -2026,7 +2026,7 @@ pandora.getVideoOptions = function(data) {
|
||||||
track: Ox.getLanguageNameByCode(track),
|
track: Ox.getLanguageNameByCode(track),
|
||||||
resolution: resolution,
|
resolution: resolution,
|
||||||
src: pandora.getVideoURL(
|
src: pandora.getVideoURL(
|
||||||
data.item || pandora.user.ui.item, resolution, i + 1, track
|
data.item || pandora.user.ui.item, resolution, i + 1, track, data.streams[i]
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -2038,7 +2038,7 @@ pandora.getVideoOptions = function(data) {
|
||||||
index: i,
|
index: i,
|
||||||
resolution: resolution,
|
resolution: resolution,
|
||||||
src: pandora.getVideoURL(
|
src: pandora.getVideoURL(
|
||||||
data.item || pandora.user.ui.item, resolution, i + 1
|
data.item || pandora.user.ui.item, resolution, i + 1, null, data.streams[i]
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -52,7 +52,7 @@ pandora.ui.videoView = function(isEmbed) {
|
||||||
pandora.api.findClips({
|
pandora.api.findClips({
|
||||||
query: query,
|
query: query,
|
||||||
itemsQuery: itemsQuery,
|
itemsQuery: itemsQuery,
|
||||||
keys: ['id', 'in', 'out', 'durations', 'parts'],
|
keys: ['id', 'in', 'out', 'durations', 'parts', 'streams'],
|
||||||
range: range,
|
range: range,
|
||||||
sort: pandora.user.ui.listSort
|
sort: pandora.user.ui.listSort
|
||||||
}, function(result) {
|
}, function(result) {
|
||||||
|
|
Loading…
Reference in a new issue