;-*-Doctest-*-

============================
Provider specific Extractors
============================

Subscribe the extractors:

    >>> from zope.configuration import xmlconfig
    >>> import p4a.plonevideoembed.metadata
    >>> _ = xmlconfig.file(
    ...     'providers.zcml', package=p4a.plonevideoembed.metadata)

Blip.tv
=======

Create and activate a link:

    >>> from p4a.plonevideoembed.metadata import testing
    >>> bliptv_link = testing.Link()

    >>> import p4a.video.interfaces
    >>> p4a.video.interfaces.IMediaActivator(
    ...     bliptv_link).media_activated = True

Select a random blip.tv video URL from the front page.  Note that the
following requires internet access:

    >>> import re, random, urllib
    >>> bliptv_link.url = "http://blip.tv%s" % random.choice(
    ...     re.findall(r"""href="(/file/[^?"']*)""",
    ...                urllib.urlopen('http://blip.tv/').read()))

Notify the event:

    >>> import zope.event
    >>> from zope.app.event import objectevent
    >>> zope.event.notify(objectevent.ObjectModifiedEvent(bliptv_link))

Now the video adapter has an FLV URL:

    >>> p4a.video.interfaces.IVideo(bliptv_link).urls
    (...(u'video/...', u'http://...')...)

Youtube
=======

Create and activate a link:

    >>> from p4a.plonevideoembed.metadata import testing
    >>> youtube_link = testing.Link()

    >>> import p4a.video.interfaces
    >>> p4a.video.interfaces.IMediaActivator(
    ...     youtube_link).media_activated = True

Select a random youtube video URL from the front page.  Note that the
following requires internet access:

    >>> import re, random, urllib
    >>> youtube_link.url = "http://youtube.com%s" % random.choice(
    ...     re.findall(r"""href="(/watch\?v=[^&"']*)""",
    ...                urllib.urlopen('http://youtube.com/').read()))

Notify the event:

    >>> import zope.event
    >>> from zope.app.event import objectevent
    >>> zope.event.notify(objectevent.ObjectModifiedEvent(youtube_link))

Now the video adapter has an FLV URL:

    >>> p4a.video.interfaces.IVideo(youtube_link).urls
    (('video/x-flv', 'http://...'),)
