Exemplo n.º 1
0
from JSI.ProviderToolbox.external.feedgenerator import Atom1Feed, rfc3339_date, get_tag_uri
from JSI.ProviderToolbox.utils import log
from JSI.ProviderToolbox.conf import settings
from JSI.ProviderToolbox.utils.exceptions import FeedGeneratorError
from JSI.RichMetadata.RichMetadata import RichMetadataGenerator

__author__ = 'D. Gabrijelcic ([email protected])'
__revision__ = '0.1'
__all__ = ['P2PNextAtomFeed', 'P2PNextLiveAtomFeed', '__revision__'] 

_log = log.getLog('FeedGenerator')

class P2PNextAtomFeed(Atom1Feed):

    def root_attributes(self):
        rd = {u"xmlns": self.ns}
        if self.feed['image'] is not None or self._items_have_image():
            rd.update({u"xmlns:p2pnext": "urn:p2pnext:contentfeed:2009"})
        if self.feed['language'] is not None:
            rd.update({u"xml:lang": self.feed['language']})
        return rd

    def _items_have_image(self):
        for i in self.items:
            if i['image'] != None:
                return True
        return False

    def _generate_item_id(self, item):
        if item['link'] == None and item["content"] == None:
            raise FeedGeneratorError("Item unique id is not specified, therefore either item link or content needs to be specified.")
Exemplo n.º 2
0
import os
import sys
from optparse import OptionParser, OptionGroup

from JSI.ProviderToolbox.ContentSource import ContentSource, Channel, ContentUnit, RTVVoDContent
from JSI.ProviderToolbox.FeedGenerator import P2PNextAtomFeed
from JSI.RichMetadata.RichMetadata import RichMetadataGenerator
from JSI.ProviderToolbox.conf import settings
from JSI.ProviderToolbox.utils import log

_log = log.getLog('discoveryfeed')
log.setLevel(log.DEBUG)

class DiscoveryFeed(object):

    def __init__(self):
        self.rmg = RichMetadataGenerator.getInstance()
        self.parser = None
        self.options = None  
        self.default_title = "P2P-Next project discovery feed"
        self.default_publisher = "P2P-Next (http://www.p2p-next.org)"
        self.default_image = "http://stream.e5.ijs.si/images/p2p-next-logo.jpg" 

    def run(self):
        """
        Runs the feed tool and creates a feed according to specified
        options
        """
        if not options.title:
            options.title = self.default_title
        if not options.exporturl:
Exemplo n.º 3
0
def sigCycleLog(signum, frame):
    logger = log.getLog('')
    log.cycleLevel()
    log.force('Log level has been changed to: ' + str(logger.level))
Exemplo n.º 4
0
from cStringIO import StringIO

from JSI.ProviderToolbox.MetadataGenerator import Feed, Item, Media, Stream, RTVSLOLiveFeed, BBCLiveFeed
from JSI.ProviderToolbox.external import feedparser
from JSI.ProviderToolbox.utils import log 
from JSI.ProviderToolbox.utils.utilities import command, asciify, textify
from JSI.ProviderToolbox.conf import settings
from JSI.RichMetadata.RichMetadata import RichMetadataGenerator
from JSI.RichMetadata.conf import metadata

# Next-Share management of the logging system is always a supprise. If
# imported before the JSI imports the basic logging config sets the
# stream handler to /dev/null. The config is run only once. Sigh.
from BaseLib.Core.TorrentDef import TorrentDef

_log = log.getLog('TestMetaGenerator')
log.setLevel(log.DEBUG)

class TestMetaGenerator(unittest.TestCase):
    """ 
    Test framework for testing generation of metadata from a feed
    """
    data = None
    
    alpha = "ABCDEFGHIJKLMNOPRSTUXYWZ"
    test_counter = 0
    run_test = True
    tests = {"A": True, #testAGetFeedMetadata
             "B": True, #testBGetItemMetadata
             "C": True, #testCFFMpegIdentify
             "D": True, #testDRichMetadata
Exemplo n.º 5
0
import urllib
import urlparse
from xml.etree.cElementTree import iterparse

from JSI.ProviderToolbox.external import feedparser
from JSI.ProviderToolbox.utils import log
from JSI.ProviderToolbox.utils.utilities import asciify, command
from JSI.ProviderToolbox.conf import settings
from JSI.RichMetadata.RichMetadata import RichMetadataGenerator

__author__ = 'D. Gabrijelcic ([email protected])'
__revision__ = '0.21'
__all__ = ['Feed', 'Item', 'Media', 'RTVSLOLiveFeed', 'BBCLiveFeed',
           '__revision__'] 

_log = log.getLog('MetadataGeneration')

class MetaGen(object):

    def __init__(self):
        self._mapper = None
        # Ignore while compare
        self._ignore = None
        # Look for meta in items
        self._meta_deep = False
        # Look for rich meta in items
        self._rich_meta_deep = False
        self._rehtml = re.compile(r'<[^<]*?/?>')
        self._recdata = re.compile(r'<!\[CDATA\[(?P<text>[^\]]*)\]\]>')
        self._initialized = True
Exemplo n.º 6
0
import os
from optparse import OptionParser, OptionGroup
import signal
import sys
import threading
import time

from JSI.ProviderToolbox.Publisher import Publisher, UpdateService
from JSI.ProviderToolbox.conf import settings
from JSI.ProviderToolbox.utils import log

_log = log.getLog('seeder')
log.setLevel(log.DEBUG)

class Seeder(object):

    def __init__(self):
        self.parser = None
        self.options = None  
        self.seeder = None
        self.update_service = None

    def run(self):
        """
        Runs the publisher tool, and serves continusly the torrent
        files in default torrent directory
        """
        self.seeder = Publisher.getInstance()
        self.seeder.start()
        self.update_service = UpdateService.getInstance(getattr(self.seeder, "update"), options.update_interval)
        self.update_service.start()
Exemplo n.º 7
0
import unittest
import urlparse
import logging
from cStringIO import StringIO

from JSI.ProviderToolbox.MetadataGenerator import Feed, Item, Media, Stream, RTVSLOLiveFeed, BBCLiveFeed
from JSI.ProviderToolbox.FeedGenerator import P2PNextAtomFeed, P2PNextLiveAtomFeed
from JSI.ProviderToolbox.external import feedparser
from JSI.ProviderToolbox.utils import log 
from JSI.ProviderToolbox.utils.exceptions import FeedGeneratorError
from JSI.ProviderToolbox.utils.utilities import textify
from JSI.ProviderToolbox.conf import settings
from JSI.RichMetadata.RichMetadata import RichMetadataGenerator
from JSI.RichMetadata.conf import metadata

_log = log.getLog('TestFeedGenerator')
log.setLevel(log.DEBUG)

class TestFeedGenerator(unittest.TestCase):
    """ 
    Test framework for testing feeds and content sources
    """
    data = None
    
    alpha = "ABCDEFGHIJKLMNOPRSTUXYWZ"
    test_counter = 0
    run_test = True
    tests = {"A": True, #testAGenerateP2PNextAtomFeed
             "B": True, #testBParseP2PNextAtomFeed
             "C": True, #testCCopyVoDFeed
             "D": True, #testDCopyLiveFeed
Exemplo n.º 8
0
import random
import time
from cStringIO import StringIO

from JSI.ProviderToolbox.FeedGenerator import P2PNextAtomFeed, P2PNextLiveAtomFeed
from JSI.ProviderToolbox.MetadataGenerator import Feed
from JSI.ProviderToolbox.external import feedparser
from JSI.ProviderToolbox.ContentSource import Channel, ContentUnit, RTVVoDContent, ContentSource
from JSI.ProviderToolbox.utils import log 
from JSI.ProviderToolbox.utils.exceptions import FeedGeneratorError
from JSI.ProviderToolbox.utils.utilities import textify
from JSI.ProviderToolbox.conf import settings
from JSI.RichMetadata.RichMetadata import RichMetadataGenerator
from JSI.RichMetadata.conf import metadata

_log = log.getLog('TestContentSource')
log.setLevel(log.DEBUG)

class TestContentSource(unittest.TestCase):
    """ 
    Test framework for testing content sources
    """
    
    alpha = "ABCDEFGHIJKLMNOPRSTUXYWZ"
    test_counter = 0
    run_test = True
    tests = {"A": True, #testAGetChannel
             "B": True, #testBExportTorrents
             "C": True, #testCSyncCheck
             "D": True, #testDCheckUpdate
             "E": True, #testEDefaultsExportFeed
Exemplo n.º 9
0
import os
import sys
from optparse import OptionParser, OptionGroup

from JSI.ProviderToolbox.ContentSource import Channel, ContentUnit, RTVVoDContent
from JSI.RichMetadata.RichMetadata import RichMetadataGenerator
from JSI.ProviderToolbox.conf import settings
from JSI.ProviderToolbox.utils import log

_log = log.getLog('getfeed')
log.setLevel(log.DEBUG)

class GetFeed(object):

    def __init__(self):
        self.rmg = RichMetadataGenerator.getInstance()
        self.parser = None
        self.options = None  
        self.mapper = {'RTVVoDContent': RTVVoDContent(),
                       'BBC': ContentUnit()}

    def run(self):
        """
        Runs the getfeed tool, fetches the content, generate torrents
        and provides P2P-Next compliant feed on std out
        """
        if options.location != None:
            template = None
            if options.template:
                if self.mapper.get(options.template):
                    template = self.mapper[options.template]
Exemplo n.º 10
0
import os
import sys
from optparse import OptionParser, OptionGroup

from JSI.ProviderToolbox.ContentSource import Channel, ContentUnit, RTVVoDContent
from JSI.RichMetadata.RichMetadata import RichMetadataGenerator
from JSI.ProviderToolbox.conf import settings
from JSI.ProviderToolbox.utils import log

_log = log.getLog('printxml')
log.setLevel(log.DEBUG)

class PrintXml(object):

    def __init__(self):
        self.rmg = RichMetadataGenerator.getInstance()
        self.parser = None
        self.options = None  

    def run(self):
        """
        Runs the printxml tool, and pretty prints the xml content on
        std output
        """
        if options.file != None:
            if os.path.exists(options.file):
                rm = self.rmg.getRichMetadata(options.file)
                if rm != None:
                    print self.rmg.prettyPrint(self.rmg.build(rm), options.encoding)
                else:
                    self.exitOnInputError("The file supplied is not in one of P2P-Next specified XML \n                    formats: " + options.file)
Exemplo n.º 11
0
import os
import sys
from optparse import OptionParser, OptionGroup

from JSI.ProviderToolbox.ContentSource import ContentSource, Channel, ContentUnit, RTVVoDContent, classpath
from JSI.ProviderToolbox.FeedGenerator import P2PNextAtomFeed
from JSI.ProviderToolbox.MetadataGenerator import Item, Media
from JSI.RichMetadata.RichMetadata import RichMetadataGenerator
from JSI.ProviderToolbox.conf import settings
from JSI.ProviderToolbox.utils import log
from JSI.ProviderToolbox.utils.utilities import textify, classImport
from JSI.RichMetadata.conf import metadata

_log = log.getLog('managefeed')
log.setLevel(log.DEBUG)

class ManageFeed(object):

    def __init__(self):
        self.rmg = RichMetadataGenerator.getInstance()
        self.parser = None
        self.options = None  

    def run(self):
        """
        Runs the managefeed tool and creates a feed according to specified
        options or modifies feed content (items)
        """
        core = None
        rmg = RichMetadataGenerator.getInstance()
        if options.coremetafile: