!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache/2.2.16 (Debian). PHP/5.3.3-7+squeeze19 

uname -a: Linux mail.tri-specialutilitydistrict.com 2.6.32-5-amd64 #1 SMP Tue May 13 16:34:35 UTC
2014 x86_64
 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/usr/share/pyshared/coherence/backends/   drwxr-xr-x
Free 129.89 GB of 142.11 GB (91.4%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     ted_storage.py (3.63 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# -*- coding: utf-8 -*-

# Licensed under the MIT license
# http://opensource.org/licenses/mit-license.php

# Copyright 2008, Benjamin Kampmann <ben.kampmann@googlemail.com>

"""
Another simple rss based Media Server, this time for TED.com content
"""

# I can reuse stuff. cool. But that also means we might want to refactor it into
# a base class to reuse
from coherence.backends.lolcats_storage import LolcatsStore
from coherence.backends.appletrailers_storage import Container

from coherence.backend import BackendItem
from coherence.upnp.core import DIDLLite

class TedTalk(BackendItem):

    def __init__(self, parent_id, id, title=None, url=None,
            duration=None, size=None):
        self.parentid = parent_id
        self.update_id = 0
        self.id = id
        self.location = url
        self.name = title

        self.item = DIDLLite.VideoItem(id, parent_id, self.name)

        res = DIDLLite.Resource(self.location, 'http-get:*:video/mp4:*') # FIXME should be video/x-m4a
        res.size = size
        res.duration = duration
        self.item.res.append(res)

class TEDStore(LolcatsStore):

    implements = ['MediaServer']

    rss_url = "http://feeds.feedburner.com/tedtalks_video?format=xml"

    ROOT_ID = 0

    def __init__(self, server, *args, **kwargs):
        BackendStore.__init__(self,server,**kwargs)

        self.name = kwargs.get('name', 'TEDtalks')
        self.refresh = int(kwargs.get('refresh', 1)) * (60 *60)

        self.next_id = 1001
        self.last_updated = None

        self.container = Container(None, self.ROOT_ID, self.name)

        self.videos = {}

        dfr = self.update_data()
        dfr.addCallback(self.init_completed)

    def get_by_id(self, id):
        if int(id) == self.ROOT_ID:
            return self.container
        return self.videos.get(int(id), None)

    def upnp_init(self):
        if self.server:
            self.server.connection_manager_server.set_variable( \
                0, 'SourceProtocolInfo', ['http-get:*:video/mp4:*'])

    def parse_data(self, xml_data):

        root = xml_data.getroot()

        pub_date = root.find('./channel/lastBuildDate').text

        if pub_date == self.last_updated:
            return

        self.last_updated = pub_date

        self.container.children = []
        self.videos = {}

        # FIXME: move these to generic constants somewhere
        mrss = './{http://search.yahoo.com/mrss/}'
        itunes = './{http://www.itunes.com/dtds/podcast-1.0.dtd}'

        url_item = mrss + 'content'
        duration = itunes + 'duration'
        summary = itunes + 'summary'

        for item in root.findall('./channel/item'):
            data = {}
            data['parent_id'] = self.ROOT_ID
            data['id'] = self.next_id
            data['title'] = item.find('./title').text.replace('TEDTalks : ', '')
            # data ['summary'] = item.find(summary).text
            # data ['duration'] = item.find(duration).text

            try:
                media_entry = item.find(url_item)
                data['url'] = media_entry.get('url', None)
                data['size'] = media_entry.get('size', None)
            except IndexError:
                continue

            video = TedTalk(**data)

            self.container.children.append(video)
            self.videos[self.next_id] = video

            self.next_id += 1

        self.container.update_id += 1
        self.update_id += 1

        if self.server:
            self.server.content_directory_server.set_variable(0, 'SystemUpdateID', self.update_id)
            value = (self.ROOT_ID,self.container.update_id)
            self.server.content_directory_server.set_variable(0, 'ContainerUpdateIDs', value)

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.0086 ]--