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

# a backend

# Copyright 2007, <NAME> <<EMAIL>>
# Copyright 2008, <NAME> <<EMAIL>>

from twisted.internet import defer

from coherence.upnp.core import utils

from coherence.upnp.core import DIDLLite
from coherence.upnp.core.DIDLLite import classChooser, Container, Resource, DIDLElement

import coherence.extern.louie as louie

from coherence.extern.simple_plugin import Plugin

from coherence import log

from urlparse import urlsplit

import re
from coherence.upnp.core.utils import getPage
from coherence.backend import BackendStore,BackendItem
from coherence.backends.picasa_storage import Container, LazyContainer, AbstractBackendStore

class PlaylistItem(BackendItem):
    logCategory = 'playlist_store'
    
    def __init__(self, title, stream_url, mimetype):

        self.name = title
        self.stream_url = stream_url
        self.mimetype = mimetype

        self.url = stream_url
        self.item = None
        
    def get_id(self):
        return self.storage_id

    def get_item(self):
        if self.item == None:
            upnp_id = self.get_id()
            upnp_parent_id = self.parent.get_id()
            item = DIDLLite.VideoItem(upnp_id, upnp_parent_id, self.name)
            
            res = Resource(self.stream_url, 'rtsp-rtp-udp:*:%s:*' % self.mimetype)
            res.size = None
            item.res.append(res)
        
            self.item = item
        return self.item
    
    def get_url(self):
        return self.url



class PlaylistStore(AbstractBackendStore):

    logCategory = 'playlist_store'
<commit_msg>publish resource with protocol http-get instead of rtsp-rtp-udp when relevant<commit_after># Licensed under the MIT license
# http://opensource.org/licenses/mit-license.php

# a backend

# Copyright 2007, <NAME> <<EMAIL>>
# Copyright 2008, <NAME> <<EMAIL>>

from twisted.internet import defer

from coherence.upnp.core import utils

from coherence.upnp.core import DIDLLite
from coherence.upnp.core.DIDLLite import classChooser, Container, Resource, DIDLElement

import coherence.extern.louie as louie

from coherence.extern.simple_plugin import Plugin

from coherence import log

from urlparse import urlsplit

import re
from coherence.upnp.core.utils import getPage
from coherence.backend import BackendStore,BackendItem
from coherence.backends.picasa_storage import Container, LazyContainer, AbstractBackendStore

class PlaylistItem(BackendItem):
    logCategory = 'playlist_store'
    
    def __init__(self, title, stream_url, mimetype):

        self.name = title
        self.stream_url = stream_url
        self.mimetype = mimetype

        self.url = stream_url
        self.item = None
        
    def get_id(self):
        return self.storage_id

    def get_item(self):
        if self.item == None:
            upnp_id = self.get_id()
            upnp_parent_id = self.parent.get_id()
            item = DIDLLite.VideoItem(upnp_id, upnp_parent_id, self.name)
            
            # what to do with MMS:// feeds?
            protocol = "http-get"
            if self.stream_url.startswith("rtsp://"):
                protocol = "rtsp-rtp-udp"
            
            res = Resource(self.stream_url, '%s:*:%s:*' % (protocol,self.mimetype))
            res.size = None
            item.res.append(res)
        
            self.item = item
        return self.item
    
    def get_url(self):
        return self.url



class PlaylistStore(AbstractBackendStore):

    logCategory = 'playlist_store'

{'fraction_non_alphanumeric': 0.08580212409167133, 'fraction_numerical': 0.004471771939631079, 'mean_word_length': 2.743723849372385, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4317405', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1067, 'n_words': 267}