Ticket #9301: scripts.2.patch

File scripts.2.patch, 17.1 KB (added by Jonatan <mythtv@…>, 10 years ago)
  • mythtv/bindings/python/MythTV/methodheap.py

     
    995995                        find('InternetContent').findall('grabber'):
    996996            yield InternetSource.fromEtree(grabber, self)
    997997
     998    def getInternetContentUrl(self, grabber, videocode):
     999        return "mythflash://%s:%s/Myth/GetInternetContent?Grabber=%s&videocode=%s" \
     1000            % (self.host, self.port, grabber, videocode)
     1001
    9981002    def getPreviewImage(self, chanid, starttime, width=None, \
    9991003                                                 height=None, secsin=None):
    10001004        starttime = datetime.duck(starttime)
  • mythtv/programs/scripts/internetcontent/nv_python_libs/vimeo/vimeo_api.py

     
    6161import xml.etree.ElementTree as ET
    6262import inspect
    6363import oauth.oauth_api as oauth
     64from MythTV import MythXML
    6465
    6566from vimeo_exceptions import (VimeoUrlError, VimeoHttpError, VimeoResponseError, VimeoVideoNotFound, VimeoRequestTokenError, VimeoAuthorizeTokenError, VimeoVideosSearchError, VimeoAllChannelError, __errmsgs__)
    6667
     
    669670
    670671        """
    671672        self.config = {}
     673        self.mythxml = MythXML()
    672674
    673675        self.config['debug_enabled'] = debug # show debugging messages
    674676
     
    980982                        if url.get('type') == 'video':
    981983                            if url.text: # Make the link fullscreen and auto play
    982984                                if embed_flag:
    983                                     v_details[url.tag] = self.ampReplace(url.text.strip().replace(u'http://vimeo.com/', u'http://vimeo.com/moogaloop.swf?clip_id=')+u'&autoplay=1')
     985                                    playerUrl = self.mythxml.getInternetContentUrl("nv_python_libs/configs/HTML/vimeo.html", \
     986                                                                                   url.text.strip().replace(u'http://vimeo.com/', ''))
     987                                    v_details[url.tag] = self.ampReplace(playerUrl)
    984988                                else:
    985989                                    v_details[url.tag] = self.ampReplace(url.text.strip())
    986990                            else:
  • mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/vimeo.html

     
     1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
     2<html>
     3    <head>
     4        <style type="text/css">
     5            body {
     6                padding: 0;
     7                margin: 0;
     8            }
     9        </style>
     10        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
     11        <script type="text/javascript">
     12            /* gup function by R.D. Vaughan */
     13            function gup( name )
     14            {
     15                name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
     16                var regexS = "[\\?&]"+name+"=([^&#]*)";
     17                var regex = new RegExp( regexS );
     18                var results = regex.exec( window.location.href );
     19                if( results == null )
     20                    return "";
     21                else
     22                    return results[1];
     23            }
     24
     25            var video_id = gup( 'videocode' );
     26            var myth_player = false;
     27            var paused = false;
     28
     29            function vimeo_player_loaded(swf_id) {
     30                myth_player = document.getElementById(swf_id);
     31                document.getElementById('controls').style.display = '';
     32            }
     33
     34            function play() {
     35                if (paused) {
     36                    myth_player.api_play();
     37                    paused = false;
     38                }
     39                else if (!paused) {
     40                    myth_player.api_pause();
     41                    paused = true;
     42                }
     43            }
     44
     45            function seek(amount) {
     46                if (myth_player) {
     47                    myth_player.api_seekTo(myth_player.api_getCurrentTime() + amount);
     48                }
     49            }
     50
     51            var flashvars = {
     52                clip_id: video_id,
     53                show_portrait: 1,
     54                show_byline: 1,
     55                show_title: 1,
     56                fp_version: 10,
     57                js_api: 1, // required in order to use the Javascript API
     58                js_onLoad: 'vimeo_player_loaded', // moogaloop will call this JS function when it's done loading (optional)
     59                js_swf_id: 'myth_player' // this will be passed into all event methods so you can keep track of multiple moogaloops (optional)
     60            };
     61            var params = {
     62                allowscriptaccess: 'always',
     63                allowfullscreen: 'true',
     64                wmode: 'opaque',
     65               
     66            };
     67            var attributes = {};
     68
     69            // For more SWFObject documentation visit: http://code.google.com/p/swfobject/wiki/documentation
     70            swfobject.embedSWF("http://vimeo.com/moogaloop.swf?autoplay=1", "myth_player", window.innerWidth, window.innerHeight, "9.0.0","expressInstall.swf", flashvars, params, attributes);
     71        </script>
     72    </head>
     73    <body>
     74        <div id="myth_player"/>
     75    </body>
     76</html>
  • mythtv/programs/scripts/internetcontent/nv_python_libs/youtube/youtube_api.py

     
    3838import os, struct, sys, re, time
    3939import urllib, urllib2
    4040import logging
     41from MythTV import MythXML
    4142
    4243try:
    4344    import xml.etree.cElementTree as ElementTree
     
    148149
    149150        """
    150151        self.config = {}
     152        self.mythxml = MythXML()
    151153
    152154        if apikey is not None:
    153155            self.config['apikey'] = apikey
     
    522524                                continue
    523525                            if not elem.get(key) == '5':
    524526                                continue
    525                             item['video'] = self.ampReplace((elem.get('url')+'&autoplay=1'))
     527                            m = re.search("/v/([^?]+)", elem.get("url"))
     528                            if m:
     529                                url = self.mythxml.getInternetContentUrl("nv_python_libs/configs/HTML/youtube.html", \
     530                                                                         m.group(1))
     531                                item['video'] = self.ampReplace(url)
     532                            else:
     533                                item['video'] = self.ampReplace((elem.get('url')+'&autoplay=1'))
    526534                            flash = True
    527535                        continue
    528536            if not item.has_key('video'):
  • mythtv/programs/scripts/internetcontent/nv_python_libs/configs/HTML/youtube.html

     
    11<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    22<html>
    3   <head>
    4   <!-- Author: R.D. Vaughan
    5        Apr 28th, 2010
    6        Purpose: Implement full screen browser video display for the BBC iPlayer
    7   Example:
    8   file:///usr/local/share/mythtv/mythnetvision/scripts/nv_python_libs/configs/HTML/bbciplayer.html?videocode=b00s5nfv
    9   -->
    10     <script type="text/javascript">
    11       function gup( name )
    12         {
    13           name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
    14           var regexS = "[\\?&]"+name+"=([^&#]*)";
    15           var regex = new RegExp( regexS );
    16           var results = regex.exec( window.location.href );
    17           if( results == null )
    18             return "";
    19           else
    20             return results[1];
    21         }
     3    <head>
     4        <style type="text/css">
     5            body {
     6                padding: 0;
     7                margin: 0;
     8            }
     9        </style>
    2210
    23       var videocode = gup( 'videocode' );
    24       var embedded = '<embed height="98%" width="100%" type="application/x-shockwave-flash" src="http://s.ytimg.com/yt/swf/watch-vfl170492.swf" id="movie_player" flashvars="rv.7.length_seconds=136&amp;rv.2.thumbnailUrl=http%3A%2F%2Fi2.ytimg.com%2Fvi%2FIFhhaXDziZ4%2Fdefault.jpg&amp;rv.0.url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DBf04aUZMIVQ&amp;rv.0.view_count=28868&amp;vq=auto&amp;rv.6.author=krlitosito&amp;rv.3.view_count=34084&amp;rv.0.length_seconds=251&amp;rv.4.thumbnailUrl=http%3A%2F%2Fi3.ytimg.com%2Fvi%2FzI9C9j0QgU4%2Fdefault.jpg&amp;fmt_url_map=34%7Chttp%3A%2F%2Fv11.lscache8.c.youtube.com%2Fvideoplayback%3Fip%3D99.0.0.0%26sparams%3Did%252Cexpire%252Cip%252Cipbits%252Citag%252Calgorithm%252Cburst%252Cfactor%26fexp%3D902303%252C906712%26algorithm%3Dthrottle-factor%26itag%3D34%26ipbits%3D8%26burst%3D40%26sver%3D3%26expire%3D1276203600%26key%3Dyt1%26signature%3D977BE213A3E74A1B3597CC270D8990872B299745.B36097223339C126F6C108E54090CDAEFE383D73%26factor%3D1.25%26id%3Db9493e8e24226592%2C5%7Chttp%3A%2F%2Fv14.lscache2.c.youtube.com%2Fvideoplayback%3Fip%3D99.0.0.0%26sparams%3Did%252Cexpire%252Cip%252Cipbits%252Citag%252Calgorithm%252Cburst%252Cfactor%26fexp%3D902303%252C906712%26algorithm%3Dthrottle-factor%26itag%3D5%26ipbits%3D8%26burst%3D40%26sver%3D3%26expire%3D1276203600%26key%3Dyt1%26signature%3D42F8774F51ED24983133B8D8F797908F97D8C371.3B0C17A6728074833130840B82BE167F4CA1035D%26factor%3D1.25%26id%3Db9493e8e24226592&amp;csi_page_type=wwad&amp;cr=CA&amp;rv.1.url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPzeRpPSZOjI&amp;rv.6.thumbnailUrl=http%3A%2F%2Fi3.ytimg.com%2Fvi%2FBwBz4h_4POA%2Fdefault.jpg&amp;host_language=en&amp;rv.3.rating=4.92660550459&amp;fmt_list=34%2F0%2F9%2F0%2F115%2C5%2F0%2F7%2F0%2F0&amp;rv.7.id=P5y-yjheRKE&amp;targeting_video_doc_id=&amp;rv.0.rating=4.97297297297&amp;invideo=True&amp;rv.5.id=6oHEgkK9wj0&amp;tk=Rqbx09U3FZ_vusI7vVWVX-zIbWbZAIm1Q2GN6gt7W3SQKWb-qm-Lvw%3D%3D&amp;sffb=True&amp;rv.0.id=Bf04aUZMIVQ&amp;rv.5.url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D6oHEgkK9wj0&amp;timestamp=1276178843&amp;rv.0.author=WaspEnterprise&amp;rv.3.thumbnailUrl=http%3A%2F%2Fi3.ytimg.com%2Fvi%2F663CI_o4sTY%2Fdefault.jpg&amp;rv.2.author=8Etech8&amp;rv.6.url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DBwBz4h_4POA&amp;ad_host=ca-host-pub-4790912793353039&amp;ad_eurl=http%3A%2F%2Fwww.youtube.com%2Fvideo%2FVIDEOCODE&amp;mpu=True&amp;hl=en_US&amp;ad_flags=1&amp;rv.0.thumbnailUrl=http%3A%2F%2Fi3.ytimg.com%2Fvi%2FBf04aUZMIVQ%2Fdefault.jpg&amp;rv.5.length_seconds=282&amp;rv.7.author=krlitosito&amp;rv.5.view_count=7517&amp;rv.1.length_seconds=251&amp;rv.3.id=663CI_o4sTY&amp;rv.2.id=IFhhaXDziZ4&amp;rv.2.length_seconds=316&amp;t=vjVQa1PpcFMjs5n51hkGar4Hp9uA3GYTt6LvegEYo00%3D&amp;rv.6.id=BwBz4h_4POA&amp;cafe_experiment_id=&amp;rv.6.view_count=2565&amp;rv.3.author=krlitosito&amp;rv.4.id=zI9C9j0QgU4&amp;fexp=902303%2C906712&amp;allow_embed=1&amp;ad_host_tier=54235&amp;fmt_stream_map=34%7Chttp%3A%2F%2Fv11.lscache8.c.youtube.com%2Fvideoplayback%3Fip%3D99.0.0.0%26sparams%3Did%252Cexpire%252Cip%252Cipbits%252Citag%252Calgorithm%252Cburst%252Cfactor%26fexp%3D902303%252C906712%26algorithm%3Dthrottle-factor%26itag%3D34%26ipbits%3D8%26burst%3D40%26sver%3D3%26expire%3D1276203600%26key%3Dyt1%26signature%3D977BE213A3E74A1B3597CC270D8990872B299745.B36097223339C126F6C108E54090CDAEFE383D73%26factor%3D1.25%26id%3Db9493e8e24226592%2C5%7Chttp%3A%2F%2Fv14.lscache2.c.youtube.com%2Fvideoplayback%3Fip%3D99.0.0.0%26sparams%3Did%252Cexpire%252Cip%252Cipbits%252Citag%252Calgorithm%252Cburst%252Cfactor%26fexp%3D902303%252C906712%26algorithm%3Dthrottle-factor%26itag%3D5%26ipbits%3D8%26burst%3D40%26sver%3D3%26expire%3D1276203600%26key%3Dyt1%26signature%3D42F8774F51ED24983133B8D8F797908F97D8C371.3B0C17A6728074833130840B82BE167F4CA1035D%26factor%3D1.25%26id%3Db9493e8e24226592&amp;rv.2.rating=4.88311688312&amp;shownextbutton=1&amp;rv.1.id=PzeRpPSZOjI&amp;rv.4.length_seconds=228&amp;ad_logging_flag=1&amp;rv.7.view_count=3940&amp;rv.6.length_seconds=253&amp;length_seconds=295&amp;fmt_map=34%2F0%2F9%2F0%2F115%2C5%2F0%2F7%2F0%2F0&amp;enablejsapi=1&amp;video_id=VIDEOCODE&amp;plid=AASIrYqnNA1liVSJ&amp;afv=True&amp;rv.5.rating=4.98&amp;ad_tag=http%3A%2F%2Fad-g.doubleclick.net%2Fpfadx%2Fcom.ytpwatch.music%2Fmain_6%3Bsz%3DWIDTHxHEIGHT%3Bmpvid%3DAASIrYqpBw0C8F4n%3B%21c%3D6%3Bytexp%3D902303.906712%3Bytps%3Ddefault%3Bklg%3Den%3Bkvid%3DVIDEOCODE%3Bctb%3D1%3Bkt%3DK%3Bko%3Dc%3Bkpid%3D6%3Bkga%3D-1%3Bkr%3DN%3Bshortform%3D1%3Bu%3DVIDEOCODE%7C6%3Bkgg%3D-1%3Bkcr%3Dca%3Bafv%3D1%3Bkhd%3D0%3Bdc_dedup%3D1%3Bkpu%3Desther1208%3B&amp;ad_video_pub_id=ca-pub-6219811747049371&amp;rv.4.url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DzI9C9j0QgU4&amp;rv.1.author=0rganix&amp;rv.1.rating=4.97674418605&amp;rv.5.thumbnailUrl=http%3A%2F%2Fi3.ytimg.com%2Fvi%2F6oHEgkK9wj0%2Fdefault.jpg&amp;watermark=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswf%2Flogo-vfl106645.swf%2Chttp%3A%2F%2Fs.ytimg.com%2Fyt%2Fswf%2Fhdlogo-vfl100714.swf&amp;rv.7.rating=4.73333333333&amp;rv.3.url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D663CI_o4sTY&amp;rv.2.url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DIFhhaXDziZ4&amp;cid=6&amp;rv.7.url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DP5y-yjheRKE&amp;rv.2.view_count=31320&amp;ad_channel_code_overlay=invideo_overlay_480x70_cat10%2Cafv_overlay%2Cafv_ugc%2Cytps_default%2Cyt_mpvid_AASIrYqpBw0C8F4n%2Cyt_cid_6%2Cytexp_902303.906712&amp;rv.4.view_count=1325763&amp;ad_module=http%3A%2F%2Fs.ytimg.com%2Fyt%2Fswf%2Fad-vfl170492.swf&amp;rv.1.view_count=22657&amp;dclk=True&amp;rv.6.rating=5.0&amp;sk=lsWSaZl1UFLCUxUw44Lon-hoi_2GTCy-C&amp;ctb=True&amp;rv.1.thumbnailUrl=http%3A%2F%2Fi1.ytimg.com%2Fvi%2FPzeRpPSZOjI%2Fdefault.jpg&amp;mpvid=AASIrYqpBw0C8F4n&amp;rv.3.length_seconds=330&amp;rv.5.author=Ulrick31&amp;rv.4.rating=4.90052939537" allowscriptaccess="always" allowfullscreen="true" bgcolor="#000000" />';
    25       document.write('<title>YouTube Full Screen</title>');
    26       document.write(embedded.replace(/VIDEOCODE/g, videocode));
     11        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
     12        <script type="text/javascript">
     13            /* gup function by R.D. Vaughan */
     14            function gup( name )
     15            {
     16                name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
     17                var regexS = "[\\?&]"+name+"=([^&#]*)";
     18                var regex = new RegExp( regexS );
     19                var results = regex.exec( window.location.href );
     20                if( results == null )
     21                    return "";
     22                else
     23                    return results[1];
     24            }
    2725
    28     </script>
    29   </head>
     26            var myth_player = null;
     27
     28            var params = {
     29            allowScriptAccess: "always",
     30                            allowfullscreen: 'true',
     31                            wmode: 'opaque'
     32            };
     33            var atts = { id: "myytplayer" };
     34            swfobject.embedSWF("http://www.youtube.com/apiplayer?enablejsapi=1&playerapiid=ytplayer",
     35                               "myth_player", window.innerWidth, window.innerHeight, "8", null, null, params, atts);
     36
     37            function onYouTubePlayerReady(playerId) {
     38                myth_player = document.getElementById("myytplayer");
     39                var videocode = gup('videocode');
     40                if (videocode != "") {
     41                    myth_player.cueVideoById(videocode);
     42                    myth_player.playVideo();
     43                }
     44            }
     45
     46            function play() {
     47                if (myth_player) {
     48                    var state = myth_player.getPlayerState();
     49                    if (state == 1) // Playing
     50                        myth_player.pauseVideo();
     51                    else if (state != 3) // Video is either unstarted, ended, paused or cued
     52                        myth_player.playVideo();
     53                }
     54            }
     55
     56            function seek(amount) {
     57                if (myth_player) {
     58                    myth_player.seekTo(myth_player.getCurrentTime() + amount, true);
     59                }
     60            }
     61
     62            window.onresize = function() {
     63                document.body.style.width = window.innerWidth;
     64                document.body.style.height = window.innerHeight;
     65                if (myth_player) {
     66                    //             myth_player.setSize(window.innerWidth, window.innerHeight);
     67                    document.getElementById("myytplayer").width = window.innerWidth;
     68                    document.getElementById("myytplayer").height = window.innerHeight;
     69                }
     70            };
     71        </script>
     72    </head>
     73    <body>
     74        <div id="myth_player"/>
     75    </body>
    3076</html>