plugins.dailymotion: initial VOD support #402

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
2 participants
@gapato
Contributor

gapato commented May 28, 2014

This adds support for Dailymotion VODs, using SegmentedStream (based on the UStream plugin). It works well in the cases I've tested, (VLC + file output which is seekable), even though I get a lot of
[flv @ 0x7f2dccc01c20] Skiping duplicate index
errors when playing the file. I'm not sure if this is a big issue.

Oops, forgot about Python 3. Will fix that.

src/livestreamer/plugins/dailymotion.py
-from livestreamer.compat import urlparse
-from livestreamer.exceptions import PluginError
+from livestreamer.compat import urlparse, unquote, urlparse

This comment has been minimized.

@chrippa

chrippa May 28, 2014

Owner

urlparse imported twice.

@chrippa

chrippa May 28, 2014

Owner

urlparse imported twice.

src/livestreamer/plugins/dailymotion.py
+ while not (segment > self.segment_max or self.closed):
+ yield segment
+ segment += 1
+

This comment has been minimized.

@chrippa

chrippa May 28, 2014

Owner

You can replace the loop with return range(1, self.segment_max + 1). But also import range from livestreamer.compat to get the iterator version of range on Python 2.

@chrippa

chrippa May 28, 2014

Owner

You can replace the loop with return range(1, self.segment_max + 1). But also import range from livestreamer.compat to get the iterator version of range on Python 2.

src/livestreamer/plugins/dailymotion.py
+
+ try:
+ # The VOD data stream is missing the right FLV header so we add it here
+ for data in self.concater.iter_chunks(buf=FLV_HEADER+res.content):

This comment has been minimized.

@chrippa

chrippa May 28, 2014

Owner

Instead of adding the FLV header you can pass skip_header=True.

@chrippa

chrippa May 28, 2014

Owner

Instead of adding the FLV header you can pass skip_header=True.

src/livestreamer/plugins/dailymotion.py
+ 'segment_min' : 1,
+ 'segment_max' : reduce(lambda i,j:i+j[0], json['fragments'], 0),
+ }
+ except:

This comment has been minimized.

@chrippa

chrippa May 28, 2014

Owner

Catching all exceptions is a bad idea. Use except KeyError: instead.

@chrippa

chrippa May 28, 2014

Owner

Catching all exceptions is a bad idea. Use except KeyError: instead.

src/livestreamer/plugins/dailymotion.py
+ def _get_vod_streams(self, channelname):
+ res = http.get(self.url)
+ match = re.search('autoURL%22%3A%22(.*?)%22', res.text)
+ if not match.groups():

This comment has been minimized.

@chrippa

chrippa May 28, 2014

Owner

This should be if not match:. match is None if pattern does not match.

@chrippa

chrippa May 28, 2014

Owner

This should be if not match:. match is None if pattern does not match.

src/livestreamer/plugins/dailymotion.py
+ match = re.search('autoURL%22%3A%22(.*?)%22', res.text)
+ if not match.groups():
+ raise PluginError('Error retrieving manifest url')
+ manifest_url = unquote(match.groups()[0]).replace('\\', '')

This comment has been minimized.

@chrippa

chrippa May 28, 2014

Owner

You can use match.group(1) here instead.

@chrippa

chrippa May 28, 2014

Owner

You can use match.group(1) here instead.

src/livestreamer/plugins/dailymotion.py
-from livestreamer.compat import urlparse
-from livestreamer.exceptions import PluginError
+from livestreamer.compat import urlparse, unquote, urlparse
+from livestreamer.exceptions import StreamError, PluginError, NoStreamsError

This comment has been minimized.

@chrippa

chrippa May 28, 2014

Owner

NoStreamsError is not used.

@chrippa

chrippa May 28, 2014

Owner

NoStreamsError is not used.

@chrippa

This comment has been minimized.

Show comment
Hide comment
@chrippa

chrippa May 28, 2014

Owner

A couple of minor issues I found and made inline comments for, other than that it look good. 👍

Owner

chrippa commented May 28, 2014

A couple of minor issues I found and made inline comments for, other than that it look good. 👍

@gapato

This comment has been minimized.

Show comment
Hide comment
@gapato

gapato May 28, 2014

Contributor

Thank you for reviewing and teaching me about match.group ! I've pushed the changes.

Contributor

gapato commented May 28, 2014

Thank you for reviewing and teaching me about match.group ! I've pushed the changes.

chrippa added a commit that referenced this pull request May 28, 2014

Merge pull request #402 from gapato/dailyvod
plugins.dailymotion: Initial VOD support
@chrippa

This comment has been minimized.

Show comment
Hide comment
@chrippa

chrippa May 28, 2014

Owner

Thanks!

Owner

chrippa commented May 28, 2014

Thanks!

@chrippa chrippa closed this May 28, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment