Loop for youtube-dl to download one of either formats (depending on errors)









up vote
1
down vote

favorite












Trying to download 100+ videos, most of which are available in "-f 43 format" I do sometimes get an error "ERROR: requested format not available".



So I'd like to have a loop that in those cases tries the same download, but in "-f 18" format (which is similar enough).



I think this should be possible, probably in bash, but I have no clear idea how. Any help is greatly appreciated!










share|improve this question

















  • 1




    Welcome to SO. Stack Overflow is a question and answer site for professional and enthusiast programmers. The goal is that you add some code of your own to your question to show at least the research effort you made to solve this yourself. Please take a look at How to create a Minimal, Complete, and Verifiable example.
    – Cyrus
    Nov 10 at 18:13










  • Thanks, I understand my question is 'bland' (or perhaps even appears lazy) but I haven't tried much more since 1) I didn't know where to start, and 2) I hoped there was some other solution (like the one below). I do genuinely appreciate your tip though, I will keep it in mind in the future.
    – marc111011
    Nov 10 at 21:13














up vote
1
down vote

favorite












Trying to download 100+ videos, most of which are available in "-f 43 format" I do sometimes get an error "ERROR: requested format not available".



So I'd like to have a loop that in those cases tries the same download, but in "-f 18" format (which is similar enough).



I think this should be possible, probably in bash, but I have no clear idea how. Any help is greatly appreciated!










share|improve this question

















  • 1




    Welcome to SO. Stack Overflow is a question and answer site for professional and enthusiast programmers. The goal is that you add some code of your own to your question to show at least the research effort you made to solve this yourself. Please take a look at How to create a Minimal, Complete, and Verifiable example.
    – Cyrus
    Nov 10 at 18:13










  • Thanks, I understand my question is 'bland' (or perhaps even appears lazy) but I haven't tried much more since 1) I didn't know where to start, and 2) I hoped there was some other solution (like the one below). I do genuinely appreciate your tip though, I will keep it in mind in the future.
    – marc111011
    Nov 10 at 21:13












up vote
1
down vote

favorite









up vote
1
down vote

favorite











Trying to download 100+ videos, most of which are available in "-f 43 format" I do sometimes get an error "ERROR: requested format not available".



So I'd like to have a loop that in those cases tries the same download, but in "-f 18" format (which is similar enough).



I think this should be possible, probably in bash, but I have no clear idea how. Any help is greatly appreciated!










share|improve this question













Trying to download 100+ videos, most of which are available in "-f 43 format" I do sometimes get an error "ERROR: requested format not available".



So I'd like to have a loop that in those cases tries the same download, but in "-f 18" format (which is similar enough).



I think this should be possible, probably in bash, but I have no clear idea how. Any help is greatly appreciated!







bash loops error-handling youtube-dl






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 18:04









marc111011

5116




5116







  • 1




    Welcome to SO. Stack Overflow is a question and answer site for professional and enthusiast programmers. The goal is that you add some code of your own to your question to show at least the research effort you made to solve this yourself. Please take a look at How to create a Minimal, Complete, and Verifiable example.
    – Cyrus
    Nov 10 at 18:13










  • Thanks, I understand my question is 'bland' (or perhaps even appears lazy) but I haven't tried much more since 1) I didn't know where to start, and 2) I hoped there was some other solution (like the one below). I do genuinely appreciate your tip though, I will keep it in mind in the future.
    – marc111011
    Nov 10 at 21:13












  • 1




    Welcome to SO. Stack Overflow is a question and answer site for professional and enthusiast programmers. The goal is that you add some code of your own to your question to show at least the research effort you made to solve this yourself. Please take a look at How to create a Minimal, Complete, and Verifiable example.
    – Cyrus
    Nov 10 at 18:13










  • Thanks, I understand my question is 'bland' (or perhaps even appears lazy) but I haven't tried much more since 1) I didn't know where to start, and 2) I hoped there was some other solution (like the one below). I do genuinely appreciate your tip though, I will keep it in mind in the future.
    – marc111011
    Nov 10 at 21:13







1




1




Welcome to SO. Stack Overflow is a question and answer site for professional and enthusiast programmers. The goal is that you add some code of your own to your question to show at least the research effort you made to solve this yourself. Please take a look at How to create a Minimal, Complete, and Verifiable example.
– Cyrus
Nov 10 at 18:13




Welcome to SO. Stack Overflow is a question and answer site for professional and enthusiast programmers. The goal is that you add some code of your own to your question to show at least the research effort you made to solve this yourself. Please take a look at How to create a Minimal, Complete, and Verifiable example.
– Cyrus
Nov 10 at 18:13












Thanks, I understand my question is 'bland' (or perhaps even appears lazy) but I haven't tried much more since 1) I didn't know where to start, and 2) I hoped there was some other solution (like the one below). I do genuinely appreciate your tip though, I will keep it in mind in the future.
– marc111011
Nov 10 at 21:13




Thanks, I understand my question is 'bland' (or perhaps even appears lazy) but I haven't tried much more since 1) I didn't know where to start, and 2) I hoped there was some other solution (like the one below). I do genuinely appreciate your tip though, I will keep it in mind in the future.
– marc111011
Nov 10 at 21:13












1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted










There is no need for external coding; youtube-dl includes this functionality natively. Simply add slashes in your -f parameter. For instance, if you want format 43, failing that 18, and failing that simply the best available single file, call youtube-dl like this:



youtube-dl -f 43/18/best https://www.youtube.com/watch?v=BaW_jenozKc


For more information, refer to the official documentation on format selection.






share|improve this answer




















    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241908%2floop-for-youtube-dl-to-download-one-of-either-formats-depending-on-errors%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    There is no need for external coding; youtube-dl includes this functionality natively. Simply add slashes in your -f parameter. For instance, if you want format 43, failing that 18, and failing that simply the best available single file, call youtube-dl like this:



    youtube-dl -f 43/18/best https://www.youtube.com/watch?v=BaW_jenozKc


    For more information, refer to the official documentation on format selection.






    share|improve this answer
























      up vote
      1
      down vote



      accepted










      There is no need for external coding; youtube-dl includes this functionality natively. Simply add slashes in your -f parameter. For instance, if you want format 43, failing that 18, and failing that simply the best available single file, call youtube-dl like this:



      youtube-dl -f 43/18/best https://www.youtube.com/watch?v=BaW_jenozKc


      For more information, refer to the official documentation on format selection.






      share|improve this answer






















        up vote
        1
        down vote



        accepted







        up vote
        1
        down vote



        accepted






        There is no need for external coding; youtube-dl includes this functionality natively. Simply add slashes in your -f parameter. For instance, if you want format 43, failing that 18, and failing that simply the best available single file, call youtube-dl like this:



        youtube-dl -f 43/18/best https://www.youtube.com/watch?v=BaW_jenozKc


        For more information, refer to the official documentation on format selection.






        share|improve this answer












        There is no need for external coding; youtube-dl includes this functionality natively. Simply add slashes in your -f parameter. For instance, if you want format 43, failing that 18, and failing that simply the best available single file, call youtube-dl like this:



        youtube-dl -f 43/18/best https://www.youtube.com/watch?v=BaW_jenozKc


        For more information, refer to the official documentation on format selection.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 10 at 19:58









        phihag

        191k47359401




        191k47359401



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241908%2floop-for-youtube-dl-to-download-one-of-either-formats-depending-on-errors%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Top Tejano songwriter Luis Silva dead of heart attack at 64

            政党

            天津地下鉄3号線