function provider_base(){this.name="";this.create_vidobj=null;this.getid=null;this.construct_watchpage_url=null;this.is_valid_vidobj=null;this.is_valid_id=null;this.formats={};this.get_format_audio_bitrate=function(a){return this.get_format_attribute(a,"audio","bitrate",-1)};this.get_format_uikey=function(a){return this.get_format_attribute(a,"dl-uikey",null,"")};this.is_format_downloadable=function(a){return this.get_format_attribute(a,"downloadable",null,false)};this.is_format_transcodable=function(a){return this.get_format_attribute(a,"transcodable",null,false)};this.get_format_attribute=function(c,d,b,a){if(!b){b=null}if(!a){a=""}if(this.formats[c]&&!b){return this.formats[c][d]}else{if(this.formats[c]&&b){return this.formats[c][d][b]}else{return a}}};this.parse_related_videos=function(d){var b=[];if((!d)||d.length<=0){return b}for(var c=0;c<d.length;c++){var e=d[c];var a=vidobj_factory().vidobj(e.id,null,e.providerstr);a.tbmap[-1]=e.tburl;a.title=e.title;a.duration=e.duration;b.push(a)}return b}}function youtube_provider(){this._self=null;this.get=function(){if(!this._self){this._self=this.init()}return this._self};this.init=function(){var a=new provider_base();a.name="youtube";a.short_name="";a.formats={"5":{container:"flv",video:{width:320,height:180,codec:"flv"},audio:{bitrate:64000,channels:2,samplerate:22050,codec:"mp3"},"dl-uikey":"video-download-yt-fmt5",transcodable:true,downloadable:true},"18":{container:"mp4",video:{width:480,height:360,codec:"flv"},audio:{bitrate:128000,channels:2,samplerate:44100,codec:"aac"},"dl-uikey":"video-download-yt-fmt18",transcodable:true,downloadable:true},"34":{container:"flv",video:{width:480,height:360,codec:"h264"},audio:{bitrate:68000,channels:2,samplerate:44100,codec:"aac"},"dl-uikey":"video-download-yt-fmt34",transcodable:true,downloadable:true},"35":{container:"flv",video:{width:640,height:480,codec:"h264"},audio:{bitrate:112000,channels:2,samplerate:44100,codec:"aac"},"dl-uikey":"video-download-yt-fmt35",transcodable:true,downloadable:true},"22":{container:"mp4",video:{width:1280,height:720,codec:"h264"},audio:{bitrate:256000,channels:2,samplerate:44100,codec:"aac"},"dl-uikey":"video-download-yt-fmt22",transcodable:true,downloadable:true},"37":{container:"mp4",video:{width:1920,height:1080,codec:"h264"},audio:{bitrate:256000,channels:2,samplerate:44100,codec:"aac"},"dl-uikey":"video-download-yt-fmt37",transcodable:false,downloadable:true},"38":{container:"mp4",video:{width:1920,height:1080,codec:"h264"},audio:{bitrate:256000,channels:2,samplerate:44100,codec:"aac"},"dl-uikey":"video-download-yt-fmt38",transcodable:false,downloadable:true}};a.construct_watchpage_url=function(b){return"http://www.youtube.com/watch?v="+b.id};a.create_vidobj=function(b){return vidobj_factory().youtube_vidobj(b)};a.is_valid_id=function(b){return is_valid_base64(b,11)};a.is_valid_vidobj=function(b){return this.is_valid_id(b.id)};a.getid=function(f){if(f.substring(0,7).toLowerCase()=="http://"){f=f.substring(7)}if(f.substring(0,4).toLowerCase()=="www."){f=f.substring(4)}var g="";if(this.is_valid_id(f)){g=f}else{if(f.substring(0,18).toLowerCase()=="youtube.com/watch?"){g=get_urlparamobj(f)["v"]}else{if(f.substring(0,18).toLowerCase()=="youtube.com/watch#"){f=f.replace("#","?");var b=get_urlparamobj(f);if(b.v&&a.is_valid_id(b.v)){g=b.v}}else{if(f.substring(0,9).toLowerCase()=="youtu.be/"){g=f.substring(9,20)}else{if(f.substring(0,24).toLowerCase()=="youtube.com/watch_videos"){var b=get_urlparamobj(f);var e=parseInt(b.index);var d=unescape(b.video_ids).split(",");if(e>=d.length){return""}else{return d[e]}}else{if(f.substring(0,17).toLowerCase()=="youtube.com/user/"){var c=get_url_fragment(f);if(c!=""){g=c.substring(c.length-11)}else{var b=get_urlparamobj(f);if(b.v&&a.is_valid_id(b.v)){g=b.v}}}}}}}}if(!g||this.is_valid_id(g)==false){return""}return g};return a};return this.get()}function vimeo_provider(){this._self=null;this.get=function(){if(!this._self){this._self=this.init()}return this._self};this.init=function(){var a=new provider_base();a.name="vimeo";a.short_name="vmo";a.formats={sd:{container:"mp4",video:{width:0,height:0,codec:"h264"},audio:{bitrate:160000,channels:2,samplerate:44100,codec:"aac"},"dl-uikey":"video-download-vmo-sd",transcodable:true,downloadable:true},hd:{container:"mp4",video:{width:0,height:0,codec:"h264"},audio:{bitrate:192000,channels:2,samplerate:44100,codec:"aac"},"dl-uikey":"video-download-vmo-hd",transcodable:true,downloadable:true}};a.construct_watchpage_url=function(b){return"http://www.vimeo.com/"+b.id};a.create_vidobj=function(b){return vidobj_factory().vimeo_vidobj(b)};a.is_valid_id=function(b){return str_isdigit(b)};a.is_valid_vidobj=function(b){return this.is_valid_id(b.id)};a.getid=function(b){var d=urlparse.urlsplit(b);if(d.path[0]=="/"){d.path=d.path.substring(1)}if(str_startswith(b,"http://")){b=b.substring(7)}if(str_startswith(b,"www.")){b=b.substring(4)}var c="";if(this.is_valid_id(d.path)){c=d.path}else{if(str_startswith(b,"vimeo.com/")&&this.is_valid_id(str_strip(d.path))){c=str_strip(d.path)}else{if(str_startswith(b,"http://vimeo.com/channels/")){c=str_strip(d.fragment)}}}if(!c||this.is_valid_id(c)==false){return""}return c};return a};return this.get()}function provider_factory(){this._self=null;this.get=function(){if(!this._self){this._self=this.init()}return this._self};this.init=function(){var a=new Object();a.provider=function(e,d){if(!d){d=""}var c=null;var b=null;b=youtube_provider();if(b.getid(e)!=""||b.name==d){c=b}return c};return a};return this.get()};