diff --git a/test_coverage/coverage_html.js b/test_coverage/coverage_html.js deleted file mode 100644 index b24006d25..000000000 --- a/test_coverage/coverage_html.js +++ /dev/null @@ -1,376 +0,0 @@ -// Coverage.py HTML report browser code. -/*jslint browser: true, sloppy: true, vars: true, plusplus: true, maxerr: 50, indent: 4 */ -/*global coverage: true, document, window, $ */ - -coverage = {}; - -// Find all the elements with shortkey_* class, and use them to assign a shotrtcut key. -coverage.assign_shortkeys = function () { - $("*[class*='shortkey_']").each(function (i, e) { - $.each($(e).attr("class").split(" "), function (i, c) { - if (/^shortkey_/.test(c)) { - $(document).bind('keydown', c.substr(9), function () { - $(e).click(); - }); - } - }); - }); -}; - -// Create the events for the help panel. -coverage.wire_up_help_panel = function () { - $("#keyboard_icon").click(function () { - // Show the help panel, and position it so the keyboard icon in the - // panel is in the same place as the keyboard icon in the header. - $(".help_panel").show(); - var koff = $("#keyboard_icon").offset(); - var poff = $("#panel_icon").position(); - $(".help_panel").offset({ - top: koff.top-poff.top, - left: koff.left-poff.left - }); - }); - $("#panel_icon").click(function () { - $(".help_panel").hide(); - }); -}; - -// Loaded on index.html -coverage.index_ready = function ($) { - // Look for a cookie containing previous sort settings: - var sort_list = []; - var cookie_name = "COVERAGE_INDEX_SORT"; - var i; - - // This almost makes it worth installing the jQuery cookie plugin: - if (document.cookie.indexOf(cookie_name) > -1) { - var cookies = document.cookie.split(";"); - for (i = 0; i < cookies.length; i++) { - var parts = cookies[i].split("="); - - if ($.trim(parts[0]) === cookie_name && parts[1]) { - sort_list = eval("[[" + parts[1] + "]]"); - break; - } - } - } - - // Create a new widget which exists only to save and restore - // the sort order: - $.tablesorter.addWidget({ - id: "persistentSort", - - // Format is called by the widget before displaying: - format: function (table) { - if (table.config.sortList.length === 0 && sort_list.length > 0) { - // This table hasn't been sorted before - we'll use - // our stored settings: - $(table).trigger('sorton', [sort_list]); - } - else { - // This is not the first load - something has - // already defined sorting so we'll just update - // our stored value to match: - sort_list = table.config.sortList; - } - } - }); - - // Configure our tablesorter to handle the variable number of - // columns produced depending on report options: - var headers = []; - var col_count = $("table.index > thead > tr > th").length; - - headers[0] = { sorter: 'text' }; - for (i = 1; i < col_count-1; i++) { - headers[i] = { sorter: 'digit' }; - } - headers[col_count-1] = { sorter: 'percent' }; - - // Enable the table sorter: - $("table.index").tablesorter({ - widgets: ['persistentSort'], - headers: headers - }); - - coverage.assign_shortkeys(); - coverage.wire_up_help_panel(); - - // Watch for page unload events so we can save the final sort settings: - $(window).unload(function () { - document.cookie = cookie_name + "=" + sort_list.toString() + "; path=/"; - }); -}; - -// -- pyfile stuff -- - -coverage.pyfile_ready = function ($) { - // If we're directed to a particular line number, highlight the line. - var frag = location.hash; - if (frag.length > 2 && frag[1] === 'n') { - $(frag).addClass('highlight'); - coverage.set_sel(parseInt(frag.substr(2), 10)); - } - else { - coverage.set_sel(0); - } - - $(document) - .bind('keydown', 'j', coverage.to_next_chunk_nicely) - .bind('keydown', 'k', coverage.to_prev_chunk_nicely) - .bind('keydown', '0', coverage.to_top) - .bind('keydown', '1', coverage.to_first_chunk) - ; - - $(".button_toggle_run").click(function (evt) {coverage.toggle_lines(evt.target, "run");}); - $(".button_toggle_exc").click(function (evt) {coverage.toggle_lines(evt.target, "exc");}); - $(".button_toggle_mis").click(function (evt) {coverage.toggle_lines(evt.target, "mis");}); - $(".button_toggle_par").click(function (evt) {coverage.toggle_lines(evt.target, "par");}); - - coverage.assign_shortkeys(); - coverage.wire_up_help_panel(); -}; - -coverage.toggle_lines = function (btn, cls) { - btn = $(btn); - var hide = "hide_"+cls; - if (btn.hasClass(hide)) { - $("#source ."+cls).removeClass(hide); - btn.removeClass(hide); - } - else { - $("#source ."+cls).addClass(hide); - btn.addClass(hide); - } -}; - -// Return the nth line div. -coverage.line_elt = function (n) { - return $("#t" + n); -}; - -// Return the nth line number div. -coverage.num_elt = function (n) { - return $("#n" + n); -}; - -// Return the container of all the code. -coverage.code_container = function () { - return $(".linenos"); -}; - -// Set the selection. b and e are line numbers. -coverage.set_sel = function (b, e) { - // The first line selected. - coverage.sel_begin = b; - // The next line not selected. - coverage.sel_end = (e === undefined) ? b+1 : e; -}; - -coverage.to_top = function () { - coverage.set_sel(0, 1); - coverage.scroll_window(0); -}; - -coverage.to_first_chunk = function () { - coverage.set_sel(0, 1); - coverage.to_next_chunk(); -}; - -coverage.is_transparent = function (color) { - // Different browsers return different colors for "none". - return color === "transparent" || color === "rgba(0, 0, 0, 0)"; -}; - -coverage.to_next_chunk = function () { - var c = coverage; - - // Find the start of the next colored chunk. - var probe = c.sel_end; - while (true) { - var probe_line = c.line_elt(probe); - if (probe_line.length === 0) { - return; - } - var color = probe_line.css("background-color"); - if (!c.is_transparent(color)) { - break; - } - probe++; - } - - // There's a next chunk, `probe` points to it. - var begin = probe; - - // Find the end of this chunk. - var next_color = color; - while (next_color === color) { - probe++; - probe_line = c.line_elt(probe); - next_color = probe_line.css("background-color"); - } - c.set_sel(begin, probe); - c.show_selection(); -}; - -coverage.to_prev_chunk = function () { - var c = coverage; - - // Find the end of the prev colored chunk. - var probe = c.sel_begin-1; - var probe_line = c.line_elt(probe); - if (probe_line.length === 0) { - return; - } - var color = probe_line.css("background-color"); - while (probe > 0 && c.is_transparent(color)) { - probe--; - probe_line = c.line_elt(probe); - if (probe_line.length === 0) { - return; - } - color = probe_line.css("background-color"); - } - - // There's a prev chunk, `probe` points to its last line. - var end = probe+1; - - // Find the beginning of this chunk. - var prev_color = color; - while (prev_color === color) { - probe--; - probe_line = c.line_elt(probe); - prev_color = probe_line.css("background-color"); - } - c.set_sel(probe+1, end); - c.show_selection(); -}; - -// Return the line number of the line nearest pixel position pos -coverage.line_at_pos = function (pos) { - var l1 = coverage.line_elt(1), - l2 = coverage.line_elt(2), - result; - if (l1.length && l2.length) { - var l1_top = l1.offset().top, - line_height = l2.offset().top - l1_top, - nlines = (pos - l1_top) / line_height; - if (nlines < 1) { - result = 1; - } - else { - result = Math.ceil(nlines); - } - } - else { - result = 1; - } - return result; -}; - -// Returns 0, 1, or 2: how many of the two ends of the selection are on -// the screen right now? -coverage.selection_ends_on_screen = function () { - if (coverage.sel_begin === 0) { - return 0; - } - - var top = coverage.line_elt(coverage.sel_begin); - var next = coverage.line_elt(coverage.sel_end-1); - - return ( - (top.isOnScreen() ? 1 : 0) + - (next.isOnScreen() ? 1 : 0) - ); -}; - -coverage.to_next_chunk_nicely = function () { - coverage.finish_scrolling(); - if (coverage.selection_ends_on_screen() === 0) { - // The selection is entirely off the screen: select the top line on - // the screen. - var win = $(window); - coverage.select_line_or_chunk(coverage.line_at_pos(win.scrollTop())); - } - coverage.to_next_chunk(); -}; - -coverage.to_prev_chunk_nicely = function () { - coverage.finish_scrolling(); - if (coverage.selection_ends_on_screen() === 0) { - var win = $(window); - coverage.select_line_or_chunk(coverage.line_at_pos(win.scrollTop() + win.height())); - } - coverage.to_prev_chunk(); -}; - -// Select line number lineno, or if it is in a colored chunk, select the -// entire chunk -coverage.select_line_or_chunk = function (lineno) { - var c = coverage; - var probe_line = c.line_elt(lineno); - if (probe_line.length === 0) { - return; - } - var the_color = probe_line.css("background-color"); - if (!c.is_transparent(the_color)) { - // The line is in a highlighted chunk. - // Search backward for the first line. - var probe = lineno; - var color = the_color; - while (probe > 0 && color === the_color) { - probe--; - probe_line = c.line_elt(probe); - if (probe_line.length === 0) { - break; - } - color = probe_line.css("background-color"); - } - var begin = probe + 1; - - // Search forward for the last line. - probe = lineno; - color = the_color; - while (color === the_color) { - probe++; - probe_line = c.line_elt(probe); - color = probe_line.css("background-color"); - } - - coverage.set_sel(begin, probe); - } - else { - coverage.set_sel(lineno); - } -}; - -coverage.show_selection = function () { - var c = coverage; - - // Highlight the lines in the chunk - c.code_container().find(".highlight").removeClass("highlight"); - for (var probe = c.sel_begin; probe > 0 && probe < c.sel_end; probe++) { - c.num_elt(probe).addClass("highlight"); - } - - c.scroll_to_selection(); -}; - -coverage.scroll_to_selection = function () { - // Scroll the page if the chunk isn't fully visible. - if (coverage.selection_ends_on_screen() < 2) { - // Need to move the page. The html,body trick makes it scroll in all - // browsers, got it from http://stackoverflow.com/questions/3042651 - var top = coverage.line_elt(coverage.sel_begin); - var top_pos = parseInt(top.offset().top, 10); - coverage.scroll_window(top_pos - 30); - } -}; - -coverage.scroll_window = function (to_pos) { - $("html,body").animate({scrollTop: to_pos}, 200); -}; - -coverage.finish_scrolling = function () { - $("html,body").stop(true, true); -}; diff --git a/test_coverage/index.html b/test_coverage/index.html deleted file mode 100644 index 2aecc71a3..000000000 --- a/test_coverage/index.html +++ /dev/null @@ -1,144 +0,0 @@ - - -
- -Hot-keys on this page
-- n - s - m - x - - c change column sorting -
-Module | -statements | -missing | -excluded | - -coverage | -
---|---|---|---|---|
Total | -3632 | -2026 | -0 | - -44% | -
youtube_dl | -274 | -251 | -0 | - -8% | -
youtube_dl.FileDownloader | -479 | -208 | -0 | - -57% | -
youtube_dl.InfoExtractors | -2275 | -1273 | -0 | - -44% | -
youtube_dl.PostProcessor | -133 | -114 | -0 | - -14% | -
youtube_dl.update | -130 | -122 | -0 | - -6% | -
youtube_dl.utils | -340 | -58 | -0 | - -83% | -
youtube_dl.version | -1 | -0 | -0 | - -100% | -
t |
":function(g,j){var o=typeof j==="string",m,p=0,q=g.length;if(o&&!/\W/.test(j))for(j=j.toLowerCase();p=0))o||m.push(t);else if(o)j[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},CHILD:function(g){if(g[1]==="nth"){var j=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=j[1]+(j[2]||1)-0;g[3]=j[3]-0}g[0]=e++;return g},ATTR:function(g,j,o, -m,p,q){j=g[1].replace(/\\/g,"");if(!q&&n.attrMap[j])g[1]=n.attrMap[j];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,j,o,m,p){if(g[1]==="not")if((d.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=l(g[3],null,null,j);else{g=l.filter(g[3],j,o,true^p);o||m.push.apply(m,g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled=== -true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,j,o){return!!l(o[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"=== -g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},setFilters:{first:function(g,j){return j===0},last:function(g,j,o,m){return j===m.length-1},even:function(g,j){return j%2===0},odd:function(g,j){return j%2===1},lt:function(g,j,o){return jo[3]-0},nth:function(g,j,o){return o[3]- -0===j},eq:function(g,j,o){return o[3]-0===j}},filter:{PSEUDO:function(g,j,o,m){var p=j[1],q=n.filters[p];if(q)return q(g,o,j,m);else if(p==="contains")return(g.textContent||g.innerText||l.getText([g])||"").indexOf(j[3])>=0;else if(p==="not"){j=j[3];o=0;for(m=j.length;o =0}},ID:function(g,j){return g.nodeType===1&&g.getAttribute("id")===j},TAG:function(g,j){return j==="*"&&g.nodeType===1||g.nodeName.toLowerCase()=== -j},CLASS:function(g,j){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(j)>-1},ATTR:function(g,j){var o=j[1];o=n.attrHandle[o]?n.attrHandle[o](g):g[o]!=null?g[o]:g.getAttribute(o);var m=o+"",p=j[2],q=j[4];return o==null?p==="!=":p==="="?m===q:p==="*="?m.indexOf(q)>=0:p==="~="?(" "+m+" ").indexOf(q)>=0:!q?m&&o!==false:p==="!="?m!==q:p==="^="?m.indexOf(q)===0:p==="$="?m.substr(m.length-q.length)===q:p==="|="?m===q||m.substr(0,q.length+1)===q+"-":false},POS:function(g,j,o,m){var p=n.setFilters[j[2]]; -if(p)return p(g,o,j,m)}}},s=n.match.POS,v=function(g,j){return"\\"+(j-0+1)},B;for(B in n.match){n.match[B]=RegExp(n.match[B].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[B]=RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[B].source.replace(/\\(\d+)/g,v))}var D=function(g,j){g=Array.prototype.slice.call(g,0);if(j){j.push.apply(j,g);return j}return g};try{Array.prototype.slice.call(u.documentElement.childNodes,0)}catch(H){D=function(g,j){var o=j||[],m=0;if(f.call(g)==="[object Array]")Array.prototype.push.apply(o, -g);else if(typeof g.length==="number")for(var p=g.length;m";var o=u.documentElement;o.insertBefore(g,o.firstChild);if(u.getElementById(j)){n.find.ID=function(m,p,q){if(typeof p.getElementById!=="undefined"&&!q)return(p=p.getElementById(m[1]))?p.id===m[1]||typeof p.getAttributeNode!=="undefined"&&p.getAttributeNode("id").nodeValue===m[1]?[p]:A:[]};n.filter.ID=function(m,p){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===p}}o.removeChild(g); -o=g=null})();(function(){var g=u.createElement("div");g.appendChild(u.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(j,o){var m=o.getElementsByTagName(j[1]);if(j[1]==="*"){for(var p=[],q=0;m[q];q++)m[q].nodeType===1&&p.push(m[q]);m=p}return m};g.innerHTML="";if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(j){return j.getAttribute("href",2)};g=null})();u.querySelectorAll&& -function(){var g=l,j=u.createElement("div");j.innerHTML="";if(!(j.querySelectorAll&&j.querySelectorAll(".TEST").length===0)){l=function(m,p,q,t){p=p||u;if(!t&&!l.isXML(p))if(p.nodeType===9)try{return D(p.querySelectorAll(m),q)}catch(x){}else if(p.nodeType===1&&p.nodeName.toLowerCase()!=="object"){var C=p.id,P=p.id="__sizzle__";try{return D(p.querySelectorAll("#"+P+" "+m),q)}catch(N){}finally{if(C)p.id=C;else p.removeAttribute("id")}}return g(m,p,q,t)};for(var o in g)l[o]=g[o]; -j=null}}();(function(){var g=u.documentElement,j=g.matchesSelector||g.mozMatchesSelector||g.webkitMatchesSelector||g.msMatchesSelector,o=false;try{j.call(u.documentElement,":sizzle")}catch(m){o=true}if(j)l.matchesSelector=function(p,q){try{if(o||!n.match.PSEUDO.test(q))return j.call(p,q)}catch(t){}return l(q,null,null,[p]).length>0}})();(function(){var g=u.createElement("div");g.innerHTML="";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length=== -0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(j,o,m){if(typeof o.getElementsByClassName!=="undefined"&&!m)return o.getElementsByClassName(j[1])};g=null}}})();l.contains=u.documentElement.contains?function(g,j){return g!==j&&(g.contains?g.contains(j):true)}:function(g,j){return!!(g.compareDocumentPosition(j)&16)};l.isXML=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false};var M=function(g, -j){for(var o=[],m="",p,q=j.nodeType?[j]:j;p=n.match.PSEUDO.exec(g);){m+=p[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;p=0;for(var t=q.length;p 0)for(var h=d;h 0},closest:function(a, -b){var d=[],e,f,h=this[0];if(c.isArray(a)){var k={},l,n=1;if(h&&a.length){e=0;for(f=a.length;e -1:c(h).is(e))d.push({selector:l,elem:h,level:n})}h=h.parentNode;n++}}return d}k=$a.test(a)?c(a,b||this.context):null;e=0;for(f=this.length;e -1:c.find.matchesSelector(h,a)){d.push(h);break}else{h=h.parentNode;if(!h|| -!h.ownerDocument||h===b)break}d=d.length>1?c.unique(d):d;return this.pushStack(d,"closest",a)},index:function(a){if(!a||typeof a==="string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var d=typeof a==="string"?c(a,b||this.context):c.makeArray(a),e=c.merge(this.get(),d);return this.pushStack(!d[0]||!d[0].parentNode||d[0].parentNode.nodeType===11||!e[0]||!e[0].parentNode||e[0].parentNode.nodeType===11?e:c.unique(e))},andSelf:function(){return this.add(this.prevObject)}}); -c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling", -d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,e){var f=c.map(this,b,d);Wa.test(a)||(e=d);if(e&&typeof e==="string")f=c.filter(e,f);f=this.length>1?c.unique(f):f;if((this.length>1||Ya.test(e))&&Xa.test(a))f=f.reverse();return this.pushStack(f,a,Za.call(arguments).join(","))}}); -c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return b.length===1?c.find.matchesSelector(b[0],a)?[b[0]]:[]:c.find.matches(a,b)},dir:function(a,b,d){var e=[];for(a=a[b];a&&a.nodeType!==9&&(d===A||a.nodeType!==1||!c(a).is(d));){a.nodeType===1&&e.push(a);a=a[b]}return e},nth:function(a,b,d){b=b||1;for(var e=0;a;a=a[d])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var xa=/ jQuery\d+="(?:\d+|null)"/g, -$=/^\s+/,ya=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,za=/<([\w:]+)/,ab=/\s]+\/)>/g,O={option:[1,""],legend:[1,""],thead:[1," ","
"],tr:[2,"","
"],td:[3,""],col:[2,"
"," "], -area:[1,""],_default:[0,"",""]};O.optgroup=O.option;O.tbody=O.tfoot=O.colgroup=O.caption=O.thead;O.th=O.td;if(!c.support.htmlSerialize)O._default=[1,"div
"," ",""];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=c(this);d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==A)return this.empty().append((this[0]&&this[0].ownerDocument||u).createTextNode(a));return c.text(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this, -d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},wrapInner:function(a){if(c.isFunction(a))return this.each(function(b){c(this).wrapInner(a.call(this,b))});return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})}, -unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a= -c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},remove:function(a,b){for(var d=0,e;(e=this[d])!=null;d++)if(!a||c.filter(a,[e]).length){if(!b&&e.nodeType===1){c.cleanData(e.getElementsByTagName("*")); -c.cleanData([e])}e.parentNode&&e.parentNode.removeChild(e)}return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++)for(b.nodeType===1&&c.cleanData(b.getElementsByTagName("*"));b.firstChild;)b.removeChild(b.firstChild);return this},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,e=this.ownerDocument;if(!d){d=e.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(xa,"").replace(cb,'="$1">').replace($, -"")],e)[0]}else return this.cloneNode(true)});if(a===true){la(this,b);la(this.find("*"),b.find("*"))}return b},html:function(a){if(a===A)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(xa,""):null;else if(typeof a==="string"&&!Aa.test(a)&&(c.support.leadingWhitespace||!$.test(a))&&!O[(za.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(ya,"<$1>$2>");try{for(var b=0,d=this.length;b0||e.cacheable||this.length>1?l.cloneNode(true):l)}k.length&&c.each(k,Ka)}return this}});c.buildFragment=function(a,b,d){var e,f,h;b=b&&b[0]?b[0].ownerDocument||b[0]:u;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&b===u&&!Aa.test(a[0])&&(c.support.checkClone|| -!Ba.test(a[0]))){f=true;if(h=c.fragments[a[0]])if(h!==1)e=h}if(!e){e=b.createDocumentFragment();c.clean(a,b,e,d)}if(f)c.fragments[a[0]]=h?e:1;return{fragment:e,cacheable:f}};c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){c.fn[a]=function(d){var e=[];d=c(d);var f=this.length===1&&this[0].parentNode;if(f&&f.nodeType===11&&f.childNodes.length===1&&d.length===1){d[b](this[0]);return this}else{f=0;for(var h= -d.length;f 0?this.clone(true):this).get();c(d[f])[b](k);e=e.concat(k)}return this.pushStack(e,a,d.selector)}}});c.extend({clean:function(a,b,d,e){b=b||u;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||u;for(var f=[],h=0,k;(k=a[h])!=null;h++){if(typeof k==="number")k+="";if(k){if(typeof k==="string"&&!bb.test(k))k=b.createTextNode(k);else if(typeof k==="string"){k=k.replace(ya,"<$1>$2>");var l=(za.exec(k)||["",""])[1].toLowerCase(),n=O[l]||O._default, -s=n[0],v=b.createElement("div");for(v.innerHTML=n[1]+k+n[2];s--;)v=v.lastChild;if(!c.support.tbody){s=ab.test(k);l=l==="table"&&!s?v.firstChild&&v.firstChild.childNodes:n[1]===" "&&!s?v.childNodes:[];for(n=l.length-1;n>=0;--n)c.nodeName(l[n],"tbody")&&!l[n].childNodes.length&&l[n].parentNode.removeChild(l[n])}!c.support.leadingWhitespace&&$.test(k)&&v.insertBefore(b.createTextNode($.exec(k)[0]),v.firstChild);k=v.childNodes}if(k.nodeType)f.push(k);else f=c.merge(f,k)}}if(d)for(h=0;f[h];h++)if(e&& -c.nodeName(f[h],"script")&&(!f[h].type||f[h].type.toLowerCase()==="text/javascript"))e.push(f[h].parentNode?f[h].parentNode.removeChild(f[h]):f[h]);else{f[h].nodeType===1&&f.splice.apply(f,[h+1,0].concat(c.makeArray(f[h].getElementsByTagName("script"))));d.appendChild(f[h])}return f},cleanData:function(a){for(var b,d,e=c.cache,f=c.event.special,h=c.support.deleteExpando,k=0,l;(l=a[k])!=null;k++)if(!(l.nodeName&&c.noData[l.nodeName.toLowerCase()]))if(d=l[c.expando]){if((b=e[d])&&b.events)for(var n in b.events)f[n]? -c.event.remove(l,n):c.removeEvent(l,n,b.handle);if(h)delete l[c.expando];else l.removeAttribute&&l.removeAttribute(c.expando);delete e[d]}}});var Ca=/alpha\([^)]*\)/i,db=/opacity=([^)]*)/,eb=/-([a-z])/ig,fb=/([A-Z])/g,Da=/^-?\d+(?:px)?$/i,gb=/^-?\d/,hb={position:"absolute",visibility:"hidden",display:"block"},La=["Left","Right"],Ma=["Top","Bottom"],W,ib=u.defaultView&&u.defaultView.getComputedStyle,jb=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){if(arguments.length===2&&b===A)return this; -return c.access(this,a,b,true,function(d,e,f){return f!==A?c.style(d,e,f):c.css(d,e)})};c.extend({cssHooks:{opacity:{get:function(a,b){if(b){var d=W(a,"opacity","opacity");return d===""?"1":d}else return a.style.opacity}}},cssNumber:{zIndex:true,fontWeight:true,opacity:true,zoom:true,lineHeight:true},cssProps:{"float":c.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,b,d,e){if(!(!a||a.nodeType===3||a.nodeType===8||!a.style)){var f,h=c.camelCase(b),k=a.style,l=c.cssHooks[h];b=c.cssProps[h]|| -h;if(d!==A){if(!(typeof d==="number"&&isNaN(d)||d==null)){if(typeof d==="number"&&!c.cssNumber[h])d+="px";if(!l||!("set"in l)||(d=l.set(a,d))!==A)try{k[b]=d}catch(n){}}}else{if(l&&"get"in l&&(f=l.get(a,false,e))!==A)return f;return k[b]}}},css:function(a,b,d){var e,f=c.camelCase(b),h=c.cssHooks[f];b=c.cssProps[f]||f;if(h&&"get"in h&&(e=h.get(a,true,d))!==A)return e;else if(W)return W(a,b,f)},swap:function(a,b,d){var e={},f;for(f in b){e[f]=a.style[f];a.style[f]=b[f]}d.call(a);for(f in b)a.style[f]= -e[f]},camelCase:function(a){return a.replace(eb,jb)}});c.curCSS=c.css;c.each(["height","width"],function(a,b){c.cssHooks[b]={get:function(d,e,f){var h;if(e){if(d.offsetWidth!==0)h=ma(d,b,f);else c.swap(d,hb,function(){h=ma(d,b,f)});return h+"px"}},set:function(d,e){if(Da.test(e)){e=parseFloat(e);if(e>=0)return e+"px"}else return e}}});if(!c.support.opacity)c.cssHooks.opacity={get:function(a,b){return db.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"": -b?"1":""},set:function(a,b){var d=a.style;d.zoom=1;var e=c.isNaN(b)?"":"alpha(opacity="+b*100+")",f=d.filter||"";d.filter=Ca.test(f)?f.replace(Ca,e):d.filter+" "+e}};if(ib)W=function(a,b,d){var e;d=d.replace(fb,"-$1").toLowerCase();if(!(b=a.ownerDocument.defaultView))return A;if(b=b.getComputedStyle(a,null)){e=b.getPropertyValue(d);if(e===""&&!c.contains(a.ownerDocument.documentElement,a))e=c.style(a,d)}return e};else if(u.documentElement.currentStyle)W=function(a,b){var d,e,f=a.currentStyle&&a.currentStyle[b], -h=a.style;if(!Da.test(f)&&gb.test(f)){d=h.left;e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;h.left=b==="fontSize"?"1em":f||0;f=h.pixelLeft+"px";h.left=d;a.runtimeStyle.left=e}return f};if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetHeight;return a.offsetWidth===0&&b===0||!c.support.reliableHiddenOffsets&&(a.style.display||c.css(a,"display"))==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var kb=c.now(),lb=/ - - - - - - - -
-- ---Coverage for youtube_dl : - 8% -
- -- 274 statements -
- - - - -- -- -Hot-keys on this page
---- r - m - x - p toggle line displays -
-- j - k next/prev highlighted chunk -
-- 0 (zero) top of page -
-- 1 (one) first highlighted chunk -
--- - - - --
-- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- -#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-- - -
- -
'Ricardo Garcia Gonzalez',
-'Danny Colligan',
-'Benjamin Johnson',
-'Vasyl\' Vavrychuk',
-'Witold Baryluk',
-'Paweł Paprota',
-'Gergely Imreh',
-'Rogério Brito',
-'Philipp Hagemeister',
-'Sören Schulze',
-'Kevin Ngo',
-'Ori Avtalion',
-'shizeeg',
-'Filippo Valsorda',
-'Christian Albrecht',
-'Dave Vasilevsky',
-'Jaime Marquínez Ferrándiz',
-)
-- -
- - - - - - - - - - -
- - - - - - -
- -
def _readOptions(filename_bytes):
-try:
-optionf = open(filename_bytes)
-except IOError:
-return [] # silently skip if file is not present
-try:
-res = []
-for l in optionf:
-res += shlex.split(l, comments=True)
-finally:
-optionf.close()
-return res
--
def _format_option_string(option):
-''' ('-o', '--option') -> -o, --format METAVAR'''
--
opts = []
--
if option._short_opts:
-opts.append(option._short_opts[0])
-if option._long_opts:
-opts.append(option._long_opts[0])
-if len(opts) > 1:
-opts.insert(1, ', ')
--
if option.takes_value(): opts.append(' %s' % option.metavar)
--
return "".join(opts)
--
def _find_term_columns():
-columns = os.environ.get('COLUMNS', None)
-if columns:
-return int(columns)
--
try:
-sp = subprocess.Popen(['stty', 'size'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-out,err = sp.communicate()
-return int(out.split()[1])
-except:
-pass
-return None
--
max_width = 80
-max_help_position = 80
--
# No need to wrap help messages if we're on a wide console
-columns = _find_term_columns()
-if columns: max_width = columns
--
fmt = optparse.IndentedHelpFormatter(width=max_width, max_help_position=max_help_position)
-fmt.format_option_strings = _format_option_string
--
kw = {
-'version' : __version__,
-'formatter' : fmt,
-'usage' : '%prog [options] url [url...]',
-'conflict_handler' : 'resolve',
-}
--
parser = optparse.OptionParser(**kw)
--
# option groups
-general = optparse.OptionGroup(parser, 'General Options')
-selection = optparse.OptionGroup(parser, 'Video Selection')
-authentication = optparse.OptionGroup(parser, 'Authentication Options')
-video_format = optparse.OptionGroup(parser, 'Video Format Options')
-postproc = optparse.OptionGroup(parser, 'Post-processing Options')
-filesystem = optparse.OptionGroup(parser, 'Filesystem Options')
-verbosity = optparse.OptionGroup(parser, 'Verbosity / Simulation Options')
--
general.add_option('-h', '--help',
-action='help', help='print this help text and exit')
-general.add_option('-v', '--version',
-action='version', help='print program version and exit')
-general.add_option('-U', '--update',
-action='store_true', dest='update_self', help='update this program to latest version')
-general.add_option('-i', '--ignore-errors',
-action='store_true', dest='ignoreerrors', help='continue on download errors', default=False)
-general.add_option('-r', '--rate-limit',
-dest='ratelimit', metavar='LIMIT', help='download rate limit (e.g. 50k or 44.6m)')
-general.add_option('-R', '--retries',
-dest='retries', metavar='RETRIES', help='number of retries (default is %default)', default=10)
-general.add_option('--buffer-size',
-dest='buffersize', metavar='SIZE', help='size of download buffer (e.g. 1024 or 16k) (default is %default)', default="1024")
-general.add_option('--no-resize-buffer',
-action='store_true', dest='noresizebuffer',
-help='do not automatically adjust the buffer size. By default, the buffer size is automatically resized from an initial value of SIZE.', default=False)
-general.add_option('--dump-user-agent',
-action='store_true', dest='dump_user_agent',
-help='display the current browser identification', default=False)
-general.add_option('--user-agent',
-dest='user_agent', help='specify a custom user agent', metavar='UA')
-general.add_option('--list-extractors',
-action='store_true', dest='list_extractors',
-help='List all supported extractors and the URLs they would handle', default=False)
-general.add_option('--test', action='store_true', dest='test', default=False, help=optparse.SUPPRESS_HELP)
--
selection.add_option('--playlist-start',
-dest='playliststart', metavar='NUMBER', help='playlist video to start at (default is %default)', default=1)
-selection.add_option('--playlist-end',
-dest='playlistend', metavar='NUMBER', help='playlist video to end at (default is last)', default=-1)
-selection.add_option('--match-title', dest='matchtitle', metavar='REGEX',help='download only matching titles (regex or caseless sub-string)')
-selection.add_option('--reject-title', dest='rejecttitle', metavar='REGEX',help='skip download for matching titles (regex or caseless sub-string)')
-selection.add_option('--max-downloads', metavar='NUMBER', dest='max_downloads', help='Abort after downloading NUMBER files', default=None)
--
authentication.add_option('-u', '--username',
-dest='username', metavar='USERNAME', help='account username')
-authentication.add_option('-p', '--password',
-dest='password', metavar='PASSWORD', help='account password')
-authentication.add_option('-n', '--netrc',
-action='store_true', dest='usenetrc', help='use .netrc authentication data', default=False)
--
-
video_format.add_option('-f', '--format',
-action='store', dest='format', metavar='FORMAT', help='video format code')
-video_format.add_option('--all-formats',
-action='store_const', dest='format', help='download all available video formats', const='all')
-video_format.add_option('--prefer-free-formats',
-action='store_true', dest='prefer_free_formats', default=False, help='prefer free video formats unless a specific one is requested')
-video_format.add_option('--max-quality',
-action='store', dest='format_limit', metavar='FORMAT', help='highest quality format to download')
-video_format.add_option('-F', '--list-formats',
-action='store_true', dest='listformats', help='list all available formats (currently youtube only)')
-video_format.add_option('--write-srt',
-action='store_true', dest='writesubtitles',
-help='write video closed captions to a .srt file (currently youtube only)', default=False)
-video_format.add_option('--srt-lang',
-action='store', dest='subtitleslang', metavar='LANG',
-help='language of the closed captions to download (optional) use IETF language tags like \'en\'')
--
-
verbosity.add_option('-q', '--quiet',
-action='store_true', dest='quiet', help='activates quiet mode', default=False)
-verbosity.add_option('-s', '--simulate',
-action='store_true', dest='simulate', help='do not download the video and do not write anything to disk', default=False)
-verbosity.add_option('--skip-download',
-action='store_true', dest='skip_download', help='do not download the video', default=False)
-verbosity.add_option('-g', '--get-url',
-action='store_true', dest='geturl', help='simulate, quiet but print URL', default=False)
-verbosity.add_option('-e', '--get-title',
-action='store_true', dest='gettitle', help='simulate, quiet but print title', default=False)
-verbosity.add_option('--get-thumbnail',
-action='store_true', dest='getthumbnail',
-help='simulate, quiet but print thumbnail URL', default=False)
-verbosity.add_option('--get-description',
-action='store_true', dest='getdescription',
-help='simulate, quiet but print video description', default=False)
-verbosity.add_option('--get-filename',
-action='store_true', dest='getfilename',
-help='simulate, quiet but print output filename', default=False)
-verbosity.add_option('--get-format',
-action='store_true', dest='getformat',
-help='simulate, quiet but print output format', default=False)
-verbosity.add_option('--no-progress',
-action='store_true', dest='noprogress', help='do not print progress bar', default=False)
-verbosity.add_option('--console-title',
-action='store_true', dest='consoletitle',
-help='display progress in console titlebar', default=False)
-verbosity.add_option('-v', '--verbose',
-action='store_true', dest='verbose', help='print various debugging information', default=False)
--
-
filesystem.add_option('-t', '--title',
-action='store_true', dest='usetitle', help='use title in file name', default=False)
-filesystem.add_option('--id',
-action='store_true', dest='useid', help='use video ID in file name', default=False)
-filesystem.add_option('-l', '--literal',
-action='store_true', dest='usetitle', help='[deprecated] alias of --title', default=False)
-filesystem.add_option('-A', '--auto-number',
-action='store_true', dest='autonumber',
-help='number downloaded files starting from 00000', default=False)
-filesystem.add_option('-o', '--output',
-dest='outtmpl', metavar='TEMPLATE', help='output filename template. Use %(title)s to get the title, %(uploader)s for the uploader name, %(uploader_id)s for the uploader nickname if different, %(autonumber)s to get an automatically incremented number, %(ext)s for the filename extension, %(upload_date)s for the upload date (YYYYMMDD), %(extractor)s for the provider (youtube, metacafe, etc), %(id)s for the video id and %% for a literal percent. Use - to output to stdout. Can also be used to download to a different directory, for example with -o \'/my/downloads/%(uploader)s/%(title)s-%(id)s.%(ext)s\' .')
-filesystem.add_option('--restrict-filenames',
-action='store_true', dest='restrictfilenames',
-help='Restrict filenames to only ASCII characters, and avoid "&" and spaces in filenames', default=False)
-filesystem.add_option('-a', '--batch-file',
-dest='batchfile', metavar='FILE', help='file containing URLs to download (\'-\' for stdin)')
-filesystem.add_option('-w', '--no-overwrites',
-action='store_true', dest='nooverwrites', help='do not overwrite files', default=False)
-filesystem.add_option('-c', '--continue',
-action='store_true', dest='continue_dl', help='resume partially downloaded files', default=True)
-filesystem.add_option('--no-continue',
-action='store_false', dest='continue_dl',
-help='do not resume partially downloaded files (restart from beginning)')
-filesystem.add_option('--cookies',
-dest='cookiefile', metavar='FILE', help='file to read cookies from and dump cookie jar in')
-filesystem.add_option('--no-part',
-action='store_true', dest='nopart', help='do not use .part files', default=False)
-filesystem.add_option('--no-mtime',
-action='store_false', dest='updatetime',
-help='do not use the Last-modified header to set the file modification time', default=True)
-filesystem.add_option('--write-description',
-action='store_true', dest='writedescription',
-help='write video description to a .description file', default=False)
-filesystem.add_option('--write-info-json',
-action='store_true', dest='writeinfojson',
-help='write video metadata to a .info.json file', default=False)
--
-
postproc.add_option('-x', '--extract-audio', action='store_true', dest='extractaudio', default=False,
-help='convert video files to audio-only files (requires ffmpeg or avconv and ffprobe or avprobe)')
-postproc.add_option('--audio-format', metavar='FORMAT', dest='audioformat', default='best',
-help='"best", "aac", "vorbis", "mp3", "m4a", or "wav"; best by default')
-postproc.add_option('--audio-quality', metavar='QUALITY', dest='audioquality', default='5',
-help='ffmpeg/avconv audio quality specification, insert a value between 0 (better) and 9 (worse) for VBR or a specific bitrate like 128K (default 5)')
-postproc.add_option('-k', '--keep-video', action='store_true', dest='keepvideo', default=False,
-help='keeps the video file on disk after the post-processing; the video is erased by default')
-postproc.add_option('--no-post-overwrites', action='store_true', dest='nopostoverwrites', default=False,
-help='do not overwrite post-processed files; the post-processed files are overwritten by default')
--
-
parser.add_option_group(general)
-parser.add_option_group(selection)
-parser.add_option_group(filesystem)
-parser.add_option_group(verbosity)
-parser.add_option_group(video_format)
-parser.add_option_group(authentication)
-parser.add_option_group(postproc)
--
xdg_config_home = os.environ.get('XDG_CONFIG_HOME')
-if xdg_config_home:
-userConf = os.path.join(xdg_config_home, 'youtube-dl.conf')
-else:
-userConf = os.path.join(os.path.expanduser('~'), '.config', 'youtube-dl.conf')
-argv = _readOptions('/etc/youtube-dl.conf') + _readOptions(userConf) + sys.argv[1:]
-opts, args = parser.parse_args(argv)
--
return parser, opts, args
-- -
parser, opts, args = parseOpts()
--
# Open appropriate CookieJar
-if opts.cookiefile is None:
-jar = compat_cookiejar.CookieJar()
-else:
-try:
-jar = compat_cookiejar.MozillaCookieJar(opts.cookiefile)
-if os.path.isfile(opts.cookiefile) and os.access(opts.cookiefile, os.R_OK):
-jar.load()
-except (IOError, OSError) as err:
-sys.exit(u'ERROR: unable to open cookie file')
-# Set user agent
-if opts.user_agent is not None:
-std_headers['User-Agent'] = opts.user_agent
--
# Dump user agent
-if opts.dump_user_agent:
-print(std_headers['User-Agent'])
-sys.exit(0)
--
# Batch file verification
-batchurls = []
-if opts.batchfile is not None:
-try:
-if opts.batchfile == '-':
-batchfd = sys.stdin
-else:
-batchfd = open(opts.batchfile, 'r')
-batchurls = batchfd.readlines()
-batchurls = [x.strip() for x in batchurls]
-batchurls = [x for x in batchurls if len(x) > 0 and not re.search(r'^[#/;]', x)]
-except IOError:
-sys.exit(u'ERROR: batch file could not be read')
-all_urls = batchurls + args
-all_urls = [url.strip() for url in all_urls]
--
# General configuration
-cookie_processor = compat_urllib_request.HTTPCookieProcessor(jar)
-proxy_handler = compat_urllib_request.ProxyHandler()
-opener = compat_urllib_request.build_opener(proxy_handler, cookie_processor, YoutubeDLHandler())
-compat_urllib_request.install_opener(opener)
-socket.setdefaulttimeout(300) # 5 minutes should be enough (famous last words)
--
extractors = gen_extractors()
--
if opts.list_extractors:
-for ie in extractors:
-print(ie.IE_NAME + (' (CURRENTLY BROKEN)' if not ie._WORKING else ''))
-matchedUrls = [url for url in all_urls if ie.suitable(url)]
-all_urls = [url for url in all_urls if url not in matchedUrls]
-for mu in matchedUrls:
-print(u' ' + mu)
-sys.exit(0)
--
# Conflicting, missing and erroneous options
-if opts.usenetrc and (opts.username is not None or opts.password is not None):
-parser.error(u'using .netrc conflicts with giving username/password')
-if opts.password is not None and opts.username is None:
-parser.error(u'account username missing')
-if opts.outtmpl is not None and (opts.usetitle or opts.autonumber or opts.useid):
-parser.error(u'using output template conflicts with using title, video ID or auto number')
-if opts.usetitle and opts.useid:
-parser.error(u'using title conflicts with using video ID')
-if opts.username is not None and opts.password is None:
-opts.password = getpass.getpass(u'Type account password and press return:')
-if opts.ratelimit is not None:
-numeric_limit = FileDownloader.parse_bytes(opts.ratelimit)
-if numeric_limit is None:
-parser.error(u'invalid rate limit specified')
-opts.ratelimit = numeric_limit
-if opts.retries is not None:
-try:
-opts.retries = int(opts.retries)
-except (TypeError, ValueError) as err:
-parser.error(u'invalid retry count specified')
-if opts.buffersize is not None:
-numeric_buffersize = FileDownloader.parse_bytes(opts.buffersize)
-if numeric_buffersize is None:
-parser.error(u'invalid buffer size specified')
-opts.buffersize = numeric_buffersize
-try:
-opts.playliststart = int(opts.playliststart)
-if opts.playliststart <= 0:
-raise ValueError(u'Playlist start must be positive')
-except (TypeError, ValueError) as err:
-parser.error(u'invalid playlist start number specified')
-try:
-opts.playlistend = int(opts.playlistend)
-if opts.playlistend != -1 and (opts.playlistend <= 0 or opts.playlistend < opts.playliststart):
-raise ValueError(u'Playlist end must be greater than playlist start')
-except (TypeError, ValueError) as err:
-parser.error(u'invalid playlist end number specified')
-if opts.extractaudio:
-if opts.audioformat not in ['best', 'aac', 'mp3', 'vorbis', 'm4a', 'wav']:
-parser.error(u'invalid audio format specified')
-if opts.audioquality:
-opts.audioquality = opts.audioquality.strip('k').strip('K')
-if not opts.audioquality.isdigit():
-parser.error(u'invalid audio quality specified')
--
if sys.version_info < (3,):
-# In Python 2, sys.argv is a bytestring (also note http://bugs.python.org/issue2128 for Windows systems)
-if opts.outtmpl is not None:
-opts.outtmpl = opts.outtmpl.decode(preferredencoding())
-outtmpl =((opts.outtmpl is not None and opts.outtmpl)
-or (opts.format == '-1' and opts.usetitle and u'%(title)s-%(id)s-%(format)s.%(ext)s')
-or (opts.format == '-1' and u'%(id)s-%(format)s.%(ext)s')
-or (opts.usetitle and opts.autonumber and u'%(autonumber)s-%(title)s-%(id)s.%(ext)s')
-or (opts.usetitle and u'%(title)s-%(id)s.%(ext)s')
-or (opts.useid and u'%(id)s.%(ext)s')
-or (opts.autonumber and u'%(autonumber)s-%(id)s.%(ext)s')
-or u'%(id)s.%(ext)s')
-# File downloader
-fd = FileDownloader({
-'usenetrc': opts.usenetrc,
-'username': opts.username,
-'password': opts.password,
-'quiet': (opts.quiet or opts.geturl or opts.gettitle or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat),
-'forceurl': opts.geturl,
-'forcetitle': opts.gettitle,
-'forcethumbnail': opts.getthumbnail,
-'forcedescription': opts.getdescription,
-'forcefilename': opts.getfilename,
-'forceformat': opts.getformat,
-'simulate': opts.simulate,
-'skip_download': (opts.skip_download or opts.simulate or opts.geturl or opts.gettitle or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat),
-'format': opts.format,
-'format_limit': opts.format_limit,
-'listformats': opts.listformats,
-'outtmpl': outtmpl,
-'restrictfilenames': opts.restrictfilenames,
-'ignoreerrors': opts.ignoreerrors,
-'ratelimit': opts.ratelimit,
-'nooverwrites': opts.nooverwrites,
-'retries': opts.retries,
-'buffersize': opts.buffersize,
-'noresizebuffer': opts.noresizebuffer,
-'continuedl': opts.continue_dl,
-'noprogress': opts.noprogress,
-'playliststart': opts.playliststart,
-'playlistend': opts.playlistend,
-'logtostderr': opts.outtmpl == '-',
-'consoletitle': opts.consoletitle,
-'nopart': opts.nopart,
-'updatetime': opts.updatetime,
-'writedescription': opts.writedescription,
-'writeinfojson': opts.writeinfojson,
-'writesubtitles': opts.writesubtitles,
-'subtitleslang': opts.subtitleslang,
-'matchtitle': opts.matchtitle,
-'rejecttitle': opts.rejecttitle,
-'max_downloads': opts.max_downloads,
-'prefer_free_formats': opts.prefer_free_formats,
-'verbose': opts.verbose,
-'test': opts.test,
-})
--
if opts.verbose:
-fd.to_screen(u'[debug] youtube-dl version ' + __version__)
-try:
-sp = subprocess.Popen(['git', 'rev-parse', '--short', 'HEAD'], stdout=subprocess.PIPE, stderr=subprocess.PIPE,
-cwd=os.path.dirname(os.path.abspath(__file__)))
-out, err = sp.communicate()
-out = out.decode().strip()
-if re.match('[0-9a-f]+', out):
-fd.to_screen(u'[debug] Git HEAD: ' + out)
-except:
-pass
-fd.to_screen(u'[debug] Python version %s - %s' %(platform.python_version(), platform.platform()))
-fd.to_screen(u'[debug] Proxy map: ' + str(proxy_handler.proxies))
--
for extractor in extractors:
-fd.add_info_extractor(extractor)
--
# PostProcessors
-if opts.extractaudio:
-fd.add_post_processor(FFmpegExtractAudioPP(preferredcodec=opts.audioformat, preferredquality=opts.audioquality, keepvideo=opts.keepvideo, nopostoverwrites=opts.nopostoverwrites))
--
# Update version
-if opts.update_self:
-update_self(fd.to_screen, opts.verbose, sys.argv[0])
--
# Maybe do nothing
-if len(all_urls) < 1:
-if not opts.update_self:
-parser.error(u'you must provide at least one URL')
-else:
-sys.exit()
--
try:
-retcode = fd.download(all_urls)
-except MaxDownloadsReached:
-fd.to_screen(u'--max-download limit reached, aborting.')
-retcode = 101
--
# Dump cookie jar if requested
-if opts.cookiefile is not None:
-try:
-jar.save()
-except (IOError, OSError) as err:
-sys.exit(u'ERROR: unable to save cookie jar')
--
sys.exit(retcode)
-- -
try:
-_real_main()
-except DownloadError:
-sys.exit(1)
-except SameFileError:
-sys.exit(u'ERROR: fixed output name but more than one file to download')
-except KeyboardInterrupt:
-sys.exit(u'\nERROR: Interrupted by user')
- -