include oshash in video url to avoid cache issues

This commit is contained in:
j 2016-08-13 15:35:20 +02:00
parent 843cea063d
commit 3d6d1be2e6
7 changed files with 21 additions and 14 deletions

View file

@ -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])
for key in keys:
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):
value = getattr(self.item.sort, key)
if value != None:
if value is not None:
j[key] = value
return j
@ -152,6 +155,7 @@ class MetaClip(object):
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['layers'] = self.get_layers(user)
data['streams'] = [s.file.oshash for s in self.item.streams()]
return data
def get_layers(self, user=None):

View file

@ -149,7 +149,7 @@ def findClips(request, data):
if 'annotations' in keys:
aqs = Annotation.objects.filter(layer__in=settings.CONFIG['clipLayers'],
clip__in=clips)
add_annotations('annotations', aqs , True)
add_annotations('annotations', aqs, True)
for layer in filter(lambda l: l in keys, layer_ids):
aqs = Annotation.objects.filter(layer=layer, clip__in=clips)

View file

@ -472,6 +472,8 @@ def get(request, data):
info = item.get_json(data['keys'])
if not data['keys'] or 'stream' in data['keys']:
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']:
info['layers'] = item.get_layers(request.user)
if data['keys'] and 'documents' in data['keys']:

View file

@ -16,7 +16,7 @@ pandora.ui.item = function() {
'audioTracks',
'cuts', 'duration', 'durations', 'editable', 'layers',
'modified', 'parts', 'posterFrame', 'rendered', 'rightslevel',
'size', 'videoRatio',
'streams', 'size', 'videoRatio',
].concat(pandora.site.itemTitleKeys) : []
}, pandora.user.ui.itemView == 'info' && pandora.site.capabilities.canEditMetadata[pandora.user.level] ? 0 : -1, function(result) {

View file

@ -95,7 +95,7 @@ pandora.ui.itemClips = function(options) {
$img = $item.find('.OxIcon > img');
points = [$item.data('in'), $item.data('out')];
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(
result.data.durations, points
),
@ -113,7 +113,8 @@ pandora.ui.itemClips = function(options) {
),
rewind: true,
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
})

View file

@ -1021,7 +1021,7 @@ pandora.getClipVideos = function(clip, resolution) {
resolution = resolution || pandora.user.ui.videoResolution;
return Ox.flatten(Ox.range(clip.parts).map(function(i) {
var item = {
src: pandora.getVideoURL(clip.item, resolution, i + 1),
src: pandora.getVideoURL(clip.item, resolution, i + 1, null, clip.streams[i]),
resolution: resolution
};
if (currentTime + clip.durations[i] <= start || currentTime > end) {
@ -1937,12 +1937,12 @@ pandora.getMediaURL = function(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 : '')
+ '.' + 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(),
prefix = pandora.site.site.videoprefix
.replace('{id}', id)
@ -1952,7 +1952,7 @@ pandora.getVideoURL = function(id, resolution, part, track) {
.replace('{uid42}', uid % 42),
local = pandora.fs && pandora.fs.getVideoURL(id, resolution, part, track);
return local || prefix + '/'
+ pandora.getVideoURLName(id, resolution, part, track);
+ pandora.getVideoURLName(id, resolution, part, track, streamId);
};
pandora.getCensoredClips = function(data) {
@ -2026,7 +2026,7 @@ pandora.getVideoOptions = function(data) {
track: Ox.getLanguageNameByCode(track),
resolution: resolution,
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,
resolution: resolution,
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]
)
});
});

View file

@ -52,7 +52,7 @@ pandora.ui.videoView = function(isEmbed) {
pandora.api.findClips({
query: query,
itemsQuery: itemsQuery,
keys: ['id', 'in', 'out', 'durations', 'parts'],
keys: ['id', 'in', 'out', 'durations', 'parts', 'streams'],
range: range,
sort: pandora.user.ui.listSort
}, function(result) {