add work in progress pandora patch
This commit is contained in:
parent
de6b146973
commit
4ccd6adb86
1 changed files with 85 additions and 0 deletions
85
pandora.patch
Normal file
85
pandora.patch
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
=== modified file 'pandora/archive/extract.py'
|
||||||
|
--- pandora/archive/extract.py 2015-02-03 18:39:22 +0000
|
||||||
|
+++ pandora/archive/extract.py 2015-03-15 09:27:50 +0000
|
||||||
|
@@ -302,7 +302,7 @@
|
||||||
|
height of frame
|
||||||
|
redo boolean to extract file even if it exists
|
||||||
|
'''
|
||||||
|
- if exists(video):
|
||||||
|
+ if video.startswith('http') or exists(video):
|
||||||
|
folder = os.path.dirname(frame)
|
||||||
|
if redo or not exists(frame):
|
||||||
|
ox.makedirs(folder)
|
||||||
|
|
||||||
|
=== modified file 'pandora/archive/models.py'
|
||||||
|
--- pandora/archive/models.py 2015-02-21 10:05:01 +0000
|
||||||
|
+++ pandora/archive/models.py 2015-03-15 10:03:47 +0000
|
||||||
|
@@ -730,11 +730,26 @@
|
||||||
|
|
||||||
|
def make_timeline(self):
|
||||||
|
if self.available and not self.source:
|
||||||
|
- extract.timeline(self.media.path, self.timeline_prefix)
|
||||||
|
+ external_url = self.info.get('url')
|
||||||
|
+ if external_url:
|
||||||
|
+ tmp = tempfile.mkdtemp()
|
||||||
|
+ path = os.path.join(tmp, '%s.%s' % (self.resolution, self.format))
|
||||||
|
+ ox.net.save_url(external_url, path)
|
||||||
|
+ info = ox.avinfo(path)
|
||||||
|
+ del info['path']
|
||||||
|
+ self.info.update(info)
|
||||||
|
+ self.file.info.update(info)
|
||||||
|
+ self.file.parse_info()
|
||||||
|
+ self.file.save()
|
||||||
|
+ else:
|
||||||
|
+ path = self.media.path
|
||||||
|
+ extract.timeline(path, self.timeline_prefix)
|
||||||
|
self.cuts = tuple(extract.cuts(self.timeline_prefix))
|
||||||
|
self.color = tuple(extract.average_color(self.timeline_prefix))
|
||||||
|
self.volume = extract.average_volume(self.timeline_prefix)
|
||||||
|
self.save()
|
||||||
|
+ if external_url:
|
||||||
|
+ shutil.rmtree(tmp)
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
if self.media and not self.info:
|
||||||
|
|
||||||
|
=== modified file 'pandora/item/models.py'
|
||||||
|
--- pandora/item/models.py 2015-02-13 11:06:09 +0000
|
||||||
|
+++ pandora/item/models.py 2015-03-15 09:28:13 +0000
|
||||||
|
@@ -1104,10 +1104,16 @@
|
||||||
|
height = stream.resolution
|
||||||
|
else:
|
||||||
|
height = min(height, stream.resolution)
|
||||||
|
+ if stream.info.get('url'):
|
||||||
|
+ stream_path = stream.info.get('url')
|
||||||
|
+ elif stream.media:
|
||||||
|
+ stream_path = stream.media.path
|
||||||
|
+ else:
|
||||||
|
+ stream_path = None
|
||||||
|
path = os.path.join(settings.MEDIA_ROOT, stream.path(),
|
||||||
|
'frames', "%dp"%height, "%s.jpg"%position)
|
||||||
|
- if not os.path.exists(path) and stream.media:
|
||||||
|
- extract.frame(stream.media.path, path, position, height, info=stream.info)
|
||||||
|
+ if not os.path.exists(path) and stream_path:
|
||||||
|
+ extract.frame(stream_path, path, position, height, info=stream.info)
|
||||||
|
if not os.path.exists(path):
|
||||||
|
return None
|
||||||
|
return path
|
||||||
|
|
||||||
|
=== modified file 'pandora/item/views.py'
|
||||||
|
--- pandora/item/views.py 2015-03-05 08:47:02 +0000
|
||||||
|
+++ pandora/item/views.py 2015-03-15 09:28:24 +0000
|
||||||
|
@@ -926,6 +926,12 @@
|
||||||
|
if index + 1 > streams.count():
|
||||||
|
raise Http404
|
||||||
|
stream = streams[index].get(resolution, format)
|
||||||
|
+ external_url = stream.info.get('url')
|
||||||
|
+ if external_url:
|
||||||
|
+ return redirect(external_url, content_type={
|
||||||
|
+ 'mp4': 'video/mp4',
|
||||||
|
+ 'webm': 'video/webm',
|
||||||
|
+ }.get(format))
|
||||||
|
if not stream.available or not stream.media:
|
||||||
|
raise Http404
|
||||||
|
path = stream.media.path
|
||||||
|
|
Loading…
Reference in a new issue