holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.83k stars 520 forks source link

Video module raises error when providing url containing query parameter #3203

Open kedarisetti opened 2 years ago

kedarisetti commented 2 years ago

ALL software version info

Panel version '0.12.6' Python 3.9.2 OS Mac Monterey

Description of expected behavior and the observed behavior

when a given video URL contains query parameter, the URL is not recognized as an URL

Complete, minimal, self-contained example code that reproduces the issue

import panel as pn
Video = pn.pane.Video
 url="https://www.videoserver.com/watch?v=/path/to/video.mp4"
Video(url)

the following error is raised

     10 
---> 11         video = Video(url,
     12                       time=5,
     13                       width=640, height=360, paused=True

~/miniconda3/envs/testing/lib/python3.9/site-packages/panel/pane/base.py in __init__(self, object, **params)
    110         applies = self.applies(object, **(params if self._applies_kw else {}))
    111         if (isinstance(applies, bool) and not applies) and object is not None :
--> 112             self._type_error(object)
    113 
    114         super().__init__(object=object, **params)

~/miniconda3/envs/testing/lib/python3.9/site-packages/panel/pane/base.py in _type_error(self, object)
    119 
    120     def _type_error(self, object):
--> 121         raise ValueError("%s pane does not support objects of type '%s'." %
    122                          (type(self).__name__, type(object).__name__))
    123 
ValueError: Video pane does not support objects of type 'str'.

Workaround

set Video._formats = None once you set the formats to None, the url passes the isUrl check

theyashl commented 1 year ago

Hi @philippjfr , as per current implementation for processing the Video URL, we are only checking if provided URL contains valid media type at the end of the path after removing query parameters. for ex.: https://www.videoserver.com/watch/path/to/video.mp4 is a valid URL but https://www.videoserver.com/watch?v=/path/to/video.mp4 is not. ref: https://github.com/holoviz/panel/blob/main/panel/util/checks.py#L37

If we try to get video resource URL from query parameter, then it'll be server specific implementation as another server may have resource path in any key of query parameter. Parsing query parameters for resource does not look right thing to me. What are your thoughts on this?