support caching local files, lookup by oshash
This commit is contained in:
parent
81ade83945
commit
b121b58a86
4 changed files with 65 additions and 18 deletions
|
|
@ -711,6 +711,16 @@ class Stream(models.Model):
|
|||
_self.update_status(ok, error)
|
||||
return _self
|
||||
|
||||
def get_index(self):
|
||||
index = 1
|
||||
for s in self.file.item.streams():
|
||||
if self.source and self.source == s:
|
||||
return index
|
||||
if s == self:
|
||||
return index
|
||||
index += 1
|
||||
return None
|
||||
|
||||
def update_status(self, ok, error):
|
||||
if ok:
|
||||
if not self.media:
|
||||
|
|
|
|||
|
|
@ -666,15 +666,21 @@ def getMediaInfo(request, data):
|
|||
id: string // oshash of media file
|
||||
}
|
||||
returns {
|
||||
item: string, // item id
|
||||
file: string // oshash of source file
|
||||
item: string, // item id
|
||||
file: string // oshash of source file
|
||||
resolution: int // stream resolution
|
||||
index: int // stream index
|
||||
}
|
||||
'''
|
||||
f = None
|
||||
resolution = None
|
||||
index = None
|
||||
qs = models.Stream.objects.filter(oshash=data['id'])
|
||||
if qs.count() > 0:
|
||||
s = qs[0]
|
||||
f = s.file
|
||||
resolution = s.resolution
|
||||
index = s.get_index()
|
||||
else:
|
||||
qs = models.File.objects.filter(oshash=data['id'])
|
||||
if qs.count() > 0:
|
||||
|
|
@ -685,6 +691,10 @@ def getMediaInfo(request, data):
|
|||
'file': f.oshash,
|
||||
'item': f.item.public_id
|
||||
}
|
||||
if resolution:
|
||||
response['data']['resolution'] = resolution
|
||||
if index:
|
||||
response['data']['index'] = index
|
||||
return render_to_json_response(response)
|
||||
actions.register(getMediaInfo)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue