Esempio n. 1
0
def _onerevver_getids(url):
    host, path, query, fragment = break_url(url)
    video_id = None
    affiliate_id = 0

    # First look for /watch/######
    match = WATCHDIGITS.search(path)
    if not match:
        # Otherwise take the last digits in the url
        # this seems to be going away
        path_elems = path.split('/')
        last_elem = path_elems.pop(-1)
        if not last_elem:
            # in case the url ends with a '/'
            last_elem = path_elems.pop(-1)
        match = FINALDIGITS.match(last_elem)
    if not match and fragment:
        # Sometimes the video_id is the url fragment (strange)
        # fortunately this seems to be going away
        match = FINALDIGITS.match(fragment)
    if match:
        # Take the first matching value
        groups =  match.groups()
        video_id = groups[0]
        if len(groups) > 1:
            affiliate_id = groups[-1] or 0
    return video_id, affiliate_id
Esempio n. 2
0
def veoh_generator(url, width):
    """ A quick check for the right url

    >>> print veoh_generator('http://www.veoh.com/videos/v360719D94bNyJd', width=400)
    <embed src="http://www.veoh.com/videodetails.swf?permalinkId=v360719D94bNyJd&id=anonymous&player=videodetailsembedded&videoAutoPlay=0" width="400" height="324" bgcolor="#000000" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>

    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.81*width))
    path_list = path.split('/')

    video_id = None
    try:
        # Use the path element imediately after '/videos/'
        video_id = path_list[path_list.index('videos')+1]
    except (ValueError, IndexError):
        return
    embed_url = urlunsplit(('http', host, 'videodetails.swf',
                            'permalinkId=%s&id=anonymous&'
                            'player=videodetailsembedded'
                            '&videoAutoPlay=0'%video_id, ''))
    tag.append('<embed src="%s" width="%s" height="%s" bgcolor="#000000" '
               'type="application/x-shockwave-flash" '
               'pluginspage="http://www.macromedia.com/go/getflashplayer">'%
                        (embed_url,
                         width,
                         height))
    tag.append('</embed>')
    return u''.join(tag)
Esempio n. 3
0
def vspot_generator(url, width):
    """ A quick check for the right url

    >>> print vspot_generator('http://www.vh1.com/vspot/?id=1557493&vid=147375', width=400)
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="392"><param name="movie" value="http://synd.vh1.com/player.jhtml"/><param name="FlashVars" value="id=1557493&vid=147375"/><param name="wmode" value="transparent"/><param name="scale" value="default"/><embed src="http://synd.vh1.com/player.jhtml" FlashVars="id=1557493&vid=147375" type="application/x-shockwave-flash" width="400" height="392" wmode="transparent" scale="default"></embed></object>

    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.98*width))

    video_id = query['vid']
    other_id = query['id']
    tag.append('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '
               'width="%s" height="%s">'%(width, height))
    tag.append('<param name="movie" value="http://synd.vh1.com/player.jhtml"/>')
    tag.append('<param name="FlashVars" value="id=%s&vid=%s"/>'%(other_id,
                                                                  video_id))
    tag.append('<param name="wmode" value="transparent"/>')
    tag.append('<param name="scale" value="default"/>')
    tag.append('<embed src="http://synd.vh1.com/player.jhtml" FlashVars="'
               'id=%s&vid=%s" type="application/x-shockwave-flash" width="%s" '
               'height="%s" wmode="transparent" scale="default">'%(other_id, video_id, width,
                                                   height))
    tag.append('</embed>')
    tag.append('</object>')
    return u''.join(tag)
Esempio n. 4
0
def collegehumor_generator(url, width):
    """ A quick check for the right url

    >>> print collegehumor_generator('http://www.collegehumor.com/video:1752121', width=400)
    <embed src="http://www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=1752121" quality="best" scale="exactfit" width="400" height="300" type="application/x-shockwave-flash"></embed>
    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.75*width))

    video_id = None
    try:
        video_id = int(path.split('%3A')[-1])
    except ValueError:
        return
    if not video_id:
        return
    embed_url = urlunsplit(('http', host, 'moogaloop/moogaloop.swf',
                            'clip_id=%s'%video_id, ''))
    tag.append('<embed src="%s" quality="best" scale="exactfit" '
               'width="%s" height="%s" '
               'type="application/x-shockwave-flash">'%(embed_url,
                                                        width,
                                                        height))
    tag.append('</embed>')
    return u''.join(tag)
Esempio n. 5
0
def superdeluxe_generator(url, width):
    """ A quick check for the right url

    >>> print superdeluxe_generator('http://www.superdeluxe.com/sd/contentDetail.do?id=D81F2344BF5AC7BB20E4789DE29A20C721C3765DC38D406E', width=400)
    <object width="400" height="350"><param name="allowFullScreen" value="true" /><param name="movie" value="http://www.superdeluxe.com/static/swf/share_vidplayer.swf" /><param name="FlashVars" value="id=D81F2344BF5AC7BB20E4789DE29A20C721C3765DC38D406E" /><embed src="http://www.superdeluxe.com/static/swf/share_vidplayer.swf" FlashVars="id=D81F2344BF5AC7BB20E4789DE29A20C721C3765DC38D406E" type="application/x-shockwave-flash" width="400" height="350" allowFullScreen="true" ></embed></object>

    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.875*width))

    video_id = query['id']
    tag.append('<object width="%s" height="%s">'%(width, height))
    tag.append('<param name="allowFullScreen" value="true" />')
    tag.append('<param name="movie" '
               'value="http://www.superdeluxe.com/static/swf/share_vidplayer.swf" />')
    tag.append('<param name="FlashVars" value="id=%s" />'%(video_id))
    tag.append('<embed src="http://www.superdeluxe.com/static/swf/share_vidplayer.swf" '
               'FlashVars="id=%s" type="application/x-shockwave-flash" '
               'width="%s" height="%s" allowFullScreen="true" >'%(video_id,
                                                                  width,
                                                                  height))
    tag.append('</embed>')
    tag.append('</object>')
    return u''.join(tag)
Esempio n. 6
0
def metacafe_generator(url, width):
    """ A quick check for the right url:

    >>> print metacafe_generator('http://www.metacafe.com/watch/344239/amazing_singing_parrot/', width=400)
    <embed src="http://www.metacafe.com/fplayer/344239/amazing_singing_parrot.swf" width="400" height="345" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.863*width))

    path_elems = path.split('/')
    last_elem = path_elems.pop(-1)
    if not last_elem:
        # in case the url ends with a '/'
        last_elem = path_elems.pop(-1)
    video_name = last_elem
    video_id = path_elems.pop(-1)
    try:
        # This should be an integer id if not fail
        int(video_id)
    except (ValueError, TypeError):
        return
    tag.append('<embed src="http://www.metacafe.com/fplayer/%s/%s.swf" '
               'width="%s" height="%s" wmode="transparent" '
               'pluginspage="http://www.macromedia.com/go/getflashplayer" '
               'type="application/x-shockwave-flash">'%(video_id, video_name, width, height))
    tag.append('</embed>')
    return u''.join(tag)
Esempio n. 7
0
def videodetective_generator(url, width):
    """ A quick check for the right url

    >>> print videodetective_generator('http://www.videodetective.com/movies/GET_SMART/trailer/P00479443.htm', width=400)
    <embed src="http://www.videodetective.com/codes/flvcodeplayer.swf" width="400" height="325" allowfullscreen="true" flashvars="&file=479443&height=325&width=400&autostart=false&shuffle=false" />
    >>> print videodetective_generator('http://www.videodetective.com/titledetails.aspx?publishedid=479443', width=400)
    <embed src="http://www.videodetective.com/codes/flvcodeplayer.swf" width="400" height="325" allowfullscreen="true" flashvars="&file=479443&height=325&width=400&autostart=false&shuffle=false" />

    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.813*width))

    video_id = query.get('publishedid', None)
    if video_id is None:
        match = VIDEO_DET.search(path)
        if match:
            video_id = int(match.groups()[0])
        else:
            return
    player_url = 'http://www.videodetective.com/codes/flvcodeplayer.swf'
    tag.append('<embed src="%s" width="%s" height="%s" allowfullscreen="true" '
               'flashvars="&file=%s&height=%s&width=%s'
               '&autostart=false&shuffle=false" />'%(player_url, width,
                                                     height, video_id,
                                                     height, width))
    return u''.join(tag)
Esempio n. 8
0
def revver_generator(url, width):
    """ A quick check for the right url

    >>> print revver_generator('http://www.revver.com/view.php?id=1111',
    ...                         width=400)
    <object codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="400" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" height="340"><param name="src" value="http://media.revver.com/broadcast/1111/video.mov" /><param name="controller" value="True" /><param name="cache" value="False" /><param name="autoplay" value="False" /><param name="kioskmode" value="False" /><param name="scale" value="aspect" /><embed src="http://media.revver.com/broadcast/1111/video.mov" pluginspage="http://www.apple.com/quicktime/download/" scale="aspect" kioskmode="False" qtsrc="http://media.revver.com/broadcast/1111/video.mov" cache="False" width="400" height="340" controller="True" type="video/quicktime" autoplay="False"></embed></object>

    >>> print revver_generator('http://www.revver.com/videos/1111/5544',
    ...                         width=400)
    <object codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="400" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" height="340"><param name="src" value="http://media.revver.com/broadcast/1111/video.mov/5544" /><param name="controller" value="True" /><param name="cache" value="False" /><param name="autoplay" value="False" /><param name="kioskmode" value="False" /><param name="scale" value="aspect" /><embed src="http://media.revver.com/broadcast/1111/video.mov/5544" pluginspage="http://www.apple.com/quicktime/download/" scale="aspect" kioskmode="False" qtsrc="http://media.revver.com/broadcast/1111/video.mov/5544" cache="False" width="400" height="340" controller="True" type="video/quicktime" autoplay="False"></embed></object>

    """
    tag = []
    host, path, query, fragment = break_url(url)
    video_ids = []
    video_id = ''
    height = int(round(0.85*width))
    if 'view.php' in path and query.has_key('id'):
        video_id = query['id']
    else:
        path_elems = path.split('/')
        while path_elems:
            # Find all integer elements
            entry = path_elems.pop(-1)
            try:
                video_ids.append(str(int(entry)))
            except ValueError:
                pass
        if video_ids:
            # the first integer in the path is the video id
            video_id = video_ids.pop(-1)
    if not video_id:
        return
    # Handle extra path id information (we don't want to short change any
    # referrers)
    extra = ''
    if video_ids:
        extra = '/' + video_ids[0]
    embed_url=urlunsplit(('http', 'media.revver.com',
                          'broadcast/%s/video.mov%s'%(video_id, extra), '', ''))
    tag.append('<object '
          'codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="%s" '
          'classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" height="%s">'%(
                      width, height))
    tag.append('<param name="src" value="%s" />'%embed_url)
    tag.append('<param name="controller" value="True" />')
    tag.append('<param name="cache" value="False" />')
    tag.append('<param name="autoplay" value="False" />')
    tag.append('<param name="kioskmode" value="False" />')
    tag.append('<param name="scale" value="aspect" />')
    tag.append('<embed src="%s" '
               'pluginspage="http://www.apple.com/quicktime/download/" '
               'scale="aspect" kioskmode="False" '
               'qtsrc="%s" cache="False" width="%s" height="%s" '
               'controller="True" type="video/quicktime" '
               'autoplay="False"></embed>'%(embed_url, embed_url,
                                            width, height))
    tag.append('</object>')
    return u''.join(tag)
Esempio n. 9
0
def _oembed_url(url):
    """Return Oembed url for the video url.

      >>> _oembed_url('http://someplace.com')
      'http://www.youtube.com/oembed?url=http%3A//someplace.com&format=json'

    """

    host, path, query, fragment = break_url(url)
    file_url = url
    return "http://www.youtube.com/oembed?url=%s&format=json" % file_url
Esempio n. 10
0
def _oembed_url(url):
    """Return Oembed url for the video url.

      >>> _oembed_url('http://someplace.com')
      'http://lab.viddler.com/services/oembed/?url=http://someplace.com?skin=rss&type=simple&format=json'

    """

    host, path, query, fragment = break_url(url)
    file_url = url
    return "http://lab.viddler.com/services/oembed/?url=%s/&&type=simple&format=json" % file_url
Esempio n. 11
0
def youtube_generator(url, width):
    """ A quick check for the right url

    >>> print youtube_generator('http://www.youtube.com/watch?v=1111',
    ...                         width=400)
    <object width="400" height="330"><param name="movie" value="http://www.youtube.com/v/1111"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/1111" type="application/x-shockwave-flash" wmode="transparent" width="400" height="330"></embed></object>

    """
    host, path, query, fragment = break_url(url)

    oembed = remote_content(_oembed_url(url))
    oembed = json.loads(oembed)
    return oembed['html']
Esempio n. 12
0
def _get_metadata_xml(url, dev_id):
    """Retrieve the remote XML for the given video url."""

    base_url = 'http://www.youtube.com/api2_rest' \
               '?method=youtube.videos.get_details' \
               '&dev_id=%(dev_id)s&video_id=%(video_id)s'

    host, path, query, fragment = break_url(url)
    video_id = query['v']
    fin = urllib2.urlopen(base_url % dict(dev_id=dev_id, video_id=video_id))
    xml = fin.read()
    fin.close()
    return xml
Esempio n. 13
0
def swf_check(url):
    """Check to see if the given url matches.

      >>> swf_check('http://someplace.com')
      False
      >>> swf_check('http://someplace.com/file.swf')
      True

    """

    host, path, query, fragment = break_url(url)
    if path.endswith('.swf'):
        return True
    return False
Esempio n. 14
0
def _rss_url(url):
    """Return RSS url for the video url.

      >>> _rss_url('http://video.google.ca/?docid=foo')
      'http://video.google.ca/videofeed?docid=foo'

      >>> _rss_url('http://video.google.ca/videoplay?docid=3758555597736903081&q=plone&total=86&start=0&num=10&so=0&type=search&plindex=0')
      'http://video.google.ca/videofeed?docid=3758555597736903081'

    """

    host, path, query, fragment = break_url(url)
    video_id = query['docid']
    return 'http://'+host+'/videofeed?docid='+video_id
Esempio n. 15
0
def google_check(url):
    """Check to see if the given url matches.

      >>> google_check('http://someplace.com')
      False
      >>> google_check('http://video.google.ca/?docid=foo')
      True

    """

    host, path, query, fragment = break_url(url)
    if host.startswith('video.google.') and query.has_key('docid'):
        return True
    return False
Esempio n. 16
0
def viddler_generator(url, width):
    """ A quick check for the right url

    >>> html = viddler_generator('http://viddler.com/explorer/user/4',
    ...                         width=400)
    >>> 'showplayer.swf?file=http%3A//blip.tv/file/get/random.flv' in html
    True

    """
    host, path, query, fragment = break_url(url)

    oembed = remote_content(_oembed_url(url))
    oembed = eval(oembed)

    return oembed["html"].replace("\\", "")
Esempio n. 17
0
def _rss_url(url):
    """Return RSS url for the video url.

      >>> _rss_url('http://someplace.com')
      'http://someplace.com?skin=rss'

      >>> _rss_url('http://someplace.com?arg1=foo')
      'http://someplace.com?arg1=foo&skin=rss'
    """

    host, path, query, fragment = break_url(url)
    file_url = url
    if len(query.keys()) == 0:
        file_url += '?skin=rss'
    else:
        file_url += '&skin=rss'
    return file_url
Esempio n. 18
0
def get_video_id(url):
    """Return the video_id of the video for the particular url.

      >>> get_video_id('http://one.revver.com/watch/1')
      1

      >>> get_video_id('http://one.revver.com/1/badpath')
      Traceback (most recent call last):
        ...
      ValueError: invalid literal for int() with base 10: 'badpath'

    """

    host, path, query, fragment = break_url(url)
    video_id = int(path.split('/')[-1])

    return video_id
Esempio n. 19
0
def dailymotion_check(url):
    """Check to see if the given url matches.

      >>> dailymotion_check('http://someplace.com')
      False
      >>> dailymotion_check('http://www.dailymotion.com/video/xc8vyu_helmut-fritz-ca-m-enerve_creation')
      True
      >>> dailymotion_check('http://www.dailymotion.com/video/xc8vyu')
      True
      >>> dailymotion_check('http://www.dailymotion.com/video/')
      False

    """
    host, path, query, fragment = break_url(url)
    if host.startswith('www.dailymotion.com') and path.startswith('/video/') \
    and len(path.split('/')[2]) > 0:
        return True
    return False
Esempio n. 20
0
def brightcove_check(url):
    """Check to see if the given url matches.

      >>> brightcove_check('http://someplace.com')
      False
      >>> brightcove_check('http://www.brightcove.tv/title.jsp?title=1320139248')
      True
      >>> brightcove_check('http://link.brightcove.com/services/link/bcpid1156009944/bclid1197714939/bctid1336727916')
      True

    """

    host, path, query, fragment = break_url(url)
    if host.endswith('brightcove.tv') and 'title' in query:
        return True
    if host.endswith('link.brightcove.com'):
        return True
    return False
Esempio n. 21
0
def bliptv_generator(url, width):
    """ A quick check for the right url

    >>> html = bliptv_generator('http://blip.tv/file/get/random.flv',
    ...                         width=400)
    >>> 'showplayer.swf?file=http%3A//blip.tv/file/get/random.flv' in html
    True

    """
    host, path, query, fragment = break_url(url)
    height = int(round(0.815*width))

    file_url = _rss_url(url)

    kwargs = dict(width=width,
                  height=height,
                  file_url=urllib.quote(file_url))

    return EMBED_HTML % kwargs
Esempio n. 22
0
def ustreamtv_generator(url, width):
    """ A quick check for the right url

    >>> html = ustreamtv_generator('http://www.ustream.tv/MrTopf/videos/SZlo2.JzT4vroml1YqwHck0MZvteE4Pm', width=400)
    >>> 'http://www.ustream.tv/SZlo2.JzT4vroml1YqwHck0MZvteE4Pm.usv' in html
    True

    """

    host, path, query, fragment = break_url(url)
    height = int(round(0.815*width))

    video_id = path.split('/')[-1]

    kwargs = dict(width=width,
                  height=height,
                  video_id=video_id)

    return EMBED_HTML % kwargs
Esempio n. 23
0
def google_generator(url, width):
    """ A quick check for the right url

    >>> print google_generator('http://video.google.com/videoplay?docid=-18281',
    ...                         width=400)
    <embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=-18281"></embed>

    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.815*width))
    video_id = query['docid']
    tag.append('<embed style="width:%spx; height:%spx;" '
               'id="VideoPlayback" type="application/x-shockwave-flash" '
               'src="http://video.google.com/googleplayer.swf?docId=%s">'%(
        width, height, video_id
        ))
    tag.append('</embed>')
    return u''.join(tag)
Esempio n. 24
0
def ifilm_generator(url, width):
    """ A quick check for the right url:

    >>> print ifilm_generator('http://www.ifilm.com/video/2690458', width=400)
    <embed width="400" height="326" src="http://www.ifilm.com/efp" quality="high" bgcolor="000000" name="efp" align="middle" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="flvbaseclip=2690458&"></embed>
    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.815*width))

    path_elems = path.split('/')
    video_id = path_elems.pop(-1)
    tag.append('<embed width="%s" height="%s" src="http://www.ifilm.com/efp" '
               'quality="high" bgcolor="000000" name="efp" align="middle" '
               'type="application/x-shockwave-flash" '
               'pluginspage="http://www.macromedia.com/go/getflashplayer" '
               'flashvars="flvbaseclip=%s&">'%(width, height, video_id))
    tag.append('</embed>')
    return u''.join(tag)
Esempio n. 25
0
def dailymotion_generator(url, width):
    """ A quick check for the right url

    >>> print dailymotion_generator('http://www.dailymotion.com/video/xajm2v_julio-cesar-skill-vs-materazzi_sport',
    ...                         width=400)
    <embed type="application/x-shockwave-flash" src="http://www.dailymotion.com/swf/video/xajm2v" width="400" allowfullscreen="true" allowscriptaccess="always"></embed>

    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.824*width))
    video_id_title = path.split('/')[2]
    video_id = video_id_title.split('_')[0]
    tag.append('<embed type="application/x-shockwave-flash" '
               'src="http://www.dailymotion.com/swf/video/%s" '
               'width="%s" allowfullscreen="true" allowscriptaccess="always">'
               ''%(video_id, width
        ))
    tag.append('</embed>')
    return u''.join(tag)
Esempio n. 26
0
def yahoo_generator(url, width):
    """ A quick check for the right url

    >>> print yahoo_generator(
    ... 'http://video.yahoo.com/video/play?vid=349edb18f0e2914a679d10f4754e689a.1106585&cache=1',
    ...                      width=400)
    <embed src="http://us.i1.yimg.com/cosmos.bcst.yahoo.com/player/media/swf/FLVVideoSolo.swf" flashvars="id=1106585&emailUrl=http%3A%2F%2Fvideo.yahoo.com%2Futil%2Fmail%3Fei%3DUTF-8%26vid%3D349edb18f0e2914a679d10f4754e689a.1106585%26cache%3D1&imUrl=http%253A%252F%252Fvideo.yahoo.com%252Fvideo%252Fplay%253Fvid%253D349edb18f0e2914a679d10f4754e689a.1106585%2526cache%253D1&imTitle=Unknown&searchUrl=http://video.yahoo.com/video/search?p=&profileUrl=http://video.yahoo.com/video/profile?yid=&creatorValue=&vid=349edb18f0e2914a679d10f4754e689a.1106585" type="application/x-shockwave-flash" width="400" height="330"></embed>

    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.824*width))
    video_id = query['vid']
    # The video id has two parts split by a . we need the latter one
    vid_end = video_id.split('.')[-1]
    title = 'Unknown'
    email_url = quote(
        'http://video.yahoo.com/util/mail?ei=UTF-8&vid=%s&cache=1' %
        video_id, '')
    # Double encode the IM url because that's what yahoo does
    im_url = quote(quote(url, ''), '')
    search_url = ('http://video.yahoo.com/video/search?p=&profileUrl='
                  'http://video.yahoo.com/video/profile?yid='
                  '&creatorValue=&vid=%s' %
                  video_id)

    tag.append('<embed '
               'src="http://us.i1.yimg.com/cosmos.bcst.yahoo.com/player'
               '/media/swf/FLVVideoSolo.swf" '
               'flashvars="id=%s'
               '&emailUrl=%s'
               '&imUrl=%s'
               '&imTitle=%s'
               '&searchUrl=%s" '
               'type="application/x-shockwave-flash" '
               'width="%s" height="%s">'%(vid_end, email_url,
                                          im_url, title,
                                          search_url, width,
                                          height))
    tag.append('</embed>')
    return u''.join(tag)
Esempio n. 27
0
def vmix_generator(url, width):
    """ A quick check for the right url

    >>> print vmix_generator('http://www.vmix.com/view.php?id=1111&type=video',
    ...                      width=400)
    <embed src="http://www.vmix.com/flash/super_player.swf?id=1111&type=video&l=0&autoStart=0"width="400" height="333" wmode="transparent"pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>

    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.833*width))
    video_id = query['id']
    p_type = query['type']
    tag.append('<embed '
'src="http://www.vmix.com/flash/super_player.swf?id=%s&type=%s&l=0&autoStart=0"'
'width="%s" height="%s" wmode="transparent"'
'pluginspage="http://www.macromedia.com/go/getflashplayer">'%(video_id,
                                                              p_type,
                                                              width,
                                                              height))
    tag.append('</embed>')
    return u''.join(tag)
Esempio n. 28
0
def bliptv_check(url):
    """Check to see if the given url is blip.tv style.

      >>> bliptv_check('http://someplace.com')
      False
      >>> bliptv_check('http://blip.tv/file/somefile.flv')
      False
      >>> bliptv_check('http://blip.tv/file/1234')
      True
      >>> bliptv_check('http://www.blip.tv/file/1234/')
      True

    """

    host, path, query, fragment = break_url(url)
    if host == 'blip.tv' or host.endswith('.blip.tv'):
        pieces = [x for x in path.split('/') if x]
        if len(pieces) == 2 \
               and pieces[0] == 'file' \
               and pieces[1].isdigit():
            return True
    return False
Esempio n. 29
0
def viddler_check(url):
    """Check to see if the given url is viddler style

      >>> viddler_check('http://someplace.com')
      False
      >>> viddler_check('http://viddler.com/file/somefile.flv')
      False
      >>> viddler_check('http://viddler.com/explore/user/34')
      True
      >>> viddler_check('http://www.viddler.com/explore/viddler/videos/20/')
      True

    """

    host, path, query, fragment = break_url(url)
    if host == "viddler.com" or host.endswith(".viddler.com"):
        pieces = [x for x in path.split("/") if x]
        if len(pieces) == 3 and pieces[0] == "explore" and pieces[2].isdigit():
            return True
        if len(pieces) == 4 and pieces[0] == "explore" and pieces[3].isdigit():
            return True
    return False
Esempio n. 30
0
def youtube_generator(url, width):
    """ A quick check for the right url

    >>> print youtube_generator('http://www.youtube.com/watch?v=1111',
    ...                         width=400)
    <object width="400" height="330"><param name="movie" value="http://www.youtube.com/v/1111"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/1111" type="application/x-shockwave-flash" wmode="transparent" width="400" height="330"></embed></object>

    """
    tag = []
    host, path, query, fragment = break_url(url)
    height = int(round(0.824*width))
    tag.append('<object width="%s" height="%s">'%(width, height))
    video_id = query['v']
    embed_url = urlunsplit(('http', host, 'v/'+video_id, '', ''))
    tag.append('<param name="movie" value="%s"></param>'%embed_url)
    tag.append('<param name="wmode" value="transparent"></param>')
    tag.append('<embed src="%s" type="application/x-shockwave-flash" '
               'wmode="transparent" '
               'width="%s" height="%s"></embed>'%(embed_url,
                                                  width, height))
    tag.append('</object>')
    return u''.join(tag)