Quantcast
Channel: Recent Discussions — Plex Forums
Viewing all articles
Browse latest Browse all 151235

Treat multiple files as one

$
0
0

I'm building a channel to play videos. Some of these videos come in multiple parts, usually of filetype .ts or .mkv. How can I have PMS treat these files sequentially, so that it seamlessly plays one after the other as though they were one file?

Here is my _ _ init.py _ _ thus far:

PREFIX = '/video/pmatches'
ART = 'art-default.jpg'
ICON = 'icon-default.png'

RSS_FEED = 'http://<URL>/matches.rss.php'

#####################################################################
# This (optional) function is initially called by the PMS framework to
# initialize the plug-in. This includes setting up the Plug-in static
# instance along with the displayed artwork.

def Start(): # Initialize the plug-in
  # Setup the default attributes for the ObjectContainer
  ObjectContainer.title1 = TITLE    
  ObjectContainer.art = R(ART)

  # Setup the default attributes for the other objects
  DirectoryObject.thumb = R(ICON)
  DirectoryObject.art = R(ART)
  VideoClipObject.thumb = R(ICON)
  VideoClipObject.art = R(ART)

# Plugin's unique identifier
# Type: Video
# Name: soccermatches
@handler(PREFIX, TITLE)

def MainMenu():
  oc = ObjectContainer()

  for match in XML.ElementFromURL(RSS_FEED).xpath('//match'):
    competition = match.xpath('./competition')[0].text
    competitor1 = match.xpath('./competitors/competitor')[0].text
    competitor2 = match.xpath('./competitors/competitor')[1].text

    title =  competition + ": " + competitor1 + " vs. " + competitor2
    Log('-------------------------------')
    Log(title)
    Log('-------------------------------')

    url = match.xpath('./link')[0].text

    summary = match.xpath('./description')[0].text
    thumb_url = match.xpath('./thumb')[0].get('url')

    oc.add(CreateVideoClipObject(
      title = title,
      thumb = thumb_url,
      url = url,
      summary = summary
    ))

  return oc

####################################################################################################
@route(PREFIX + '/createvideoclipobject', include_container=bool)
def CreateVideoClipObject(title, thumb, url, summary, include_container=False, *args, **kwargs):

  video_object = VideoClipObject(
    key=Callback(CreateVideoClipObject, title=title, thumb=thumb, url=url, summary=summary, include_container=True),
    rating_key=url,
    title=title,
    thumb=thumb,
    content_rating='NR',
    url=url,
    summary=summary,
    art=thumb,
    items=GetMediaObject(url)
    )

  if include_container:
    return ObjectContainer(objects=[video_object])

  else:
    return video_object

####################################################################################################
def GetMediaObject(url):

    mo = [
        MediaObject(
            parts=[PartObject(key=Callback(PlayVideo, url=url))],
            container = Container.MP4,
            video_codec = VideoCodec.H264,
            audio_codec = AudioCodec.AAC,
            audio_channels = 2,
            optimized_for_streaming = True
            )
        ]

    return mo

####################################################################################################
@indirect
# @route(PREFIX + '/playvideo.m3u8')
def PlayVideo(url, **kwargs):

    return IndirectResponse(VideoClipObject, key=url)

Viewing all articles
Browse latest Browse all 151235

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>