import panel as pn
pn.pane.Video("https://file-examples-com.github.io/uploads/2017/04/file_example_MP4_480_1_5MG.mp4?hello=world")
Should I not be doing this? If this is just an oversight in the method would it be sensible to replace the logic of isurl so that it validates using a proper url library and ignores parameters?
@Marc@philippjfr I just realised that this does not completely fix my original problem because I had hacked in a fix locally and never tested this one. The second issue for me was that I was using a presigned url to fetch the video and it looks like this: https://some-user.s3.amazonaws.com/media/video/457874dsfsd-dfdsfd-erer-45454-dfdf/original_safeguarded?AWSAccessKeyId=ASDFJDFD34384739784DFD&Signature=SDFSD545345DFGDFG&Expires=162469845984
Essentially the object has no file ending because it is just stored with a uuid on cloud storage. It seems the other issue was that this part of the check and (formats is None or any(lower_string.endswith('.'+fmt) for fmt in formats))
also fails.
Is there a better way to do the validation for valid formats? I actually donβt know a solution off the top of my head. Happy to do the PR with a little assistance.
As I see it there is no general solution for this as the .applies is used guess which panel to apply to an unknown object. Normally you would not use Video on any url.
But you might be able to create a CustomVideo class supporting your use case. Something along the lines of
import panel as pn
class CustomVideo(pn.pane.Video):
@classmethod
def applies(cls, obj):
if isinstance(obj, str) and str.startswith("https://some-user.s3.amazonaws.com/media/video/"):
return True
return super(pn.pane.Video, cls).applies(obj)
CustomVideo("https://some-user.s3.amazonaws.com/media/video/457874dsfsd-dfdsfd-erer-45454-dfdf/original_safeguarded?AWSAccessKeyId=ASDFJDFD34384739784DFD&Signature=SDFSD545345DFGDFG&Expires=162469845984")
Thanks for the suggestion @Marc . I can see why the restriction is there. I think your suggestion is nice and pragmatic. I will give it a go and let you know.