Error fixed output name but more than one file to download

Checklist I'm asking a question I've looked through the README and FAQ for similar questions I've searched the bugtracker for similar questions including closed ones Question I am new t...

@ritualisticoffee

Checklist

  • I’m asking a question
  • I’ve looked through the README and FAQ for similar questions
  • I’ve searched the bugtracker for similar questions including closed ones

Question

I am new to Youtube-DL and not much of a programmer so apologies if I am asking some silly questions here.

I have created a config file for the purpose of setting a default download location. I keep getting one of two errors:
1 — «Fixed output name but more than one file to download» or
2- «no such option: -«
when trying to set the path for Youtube-DL using the terminal command «youtube-dl —config-location ~/.config/youtube-dl.conf.rtf».

I think the issue comes from the path that I am pointing to containing spaces. I am trying to set the download location using:

-o ~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s

however, this threw up the first error «…more than one file to download». Upon googling I thought it might be the spaces causing the issue so I tried using:

-o "~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s"

which again threw up the first error. I also tried using backslashes:

-o ~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s

which threw up the second error «no such option: -«.

I’m not sure what I’m missing here, or if it is not possible to point to a path which includes spaces.
I have also tried various combinations of quotes and backslashes which have all given one of the two errors in response.

@dirkf

We’re in a POSIX system where ~ expands to the user’s home directory.

-o ~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s

This means:

  • use a fixed destination ~/Documents/2
  • download URLs - and Personal/Youtube-DL/%(title)s.%(ext)s

That’s why yt-dl says «…more than one file to download».

-o "~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s"
which again threw up the first error. …

This looks a lot better, and works for me, but in a POSIX shell, prefer single quotes unless the quoted text needs to be modified by the shell (eg ${var_to_be_included}). Please try again and post the log, similar to this:

$ python -m youtube_dl --get-filename -f 22 -o "~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s" BaW_jenozKc 
/home/df/Documents/2 - Personal/Youtube-DL/youtube-dl test video ''_ä↭𝕐.mp4
$

-o ~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s

Here you also have to escape the ():

$ python -m youtube_dl --get-filename -f 22 -o ~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s BaW_jenozKc 
/home/df/Documents/2 - Personal/Youtube-DL/youtube-dl test video ''_ä↭𝕐.mp4
$

Using '' is a lot easier.

Since this clearly works on the command line there may be a problem with parsing the option and value from a config file.

@dirkf

The rules for parsing a config file may not be clearly stated anywhere.

yt-dl uses the Python library function shlex.split() with comments and POSIX mode enabled. Thus these rules apply:

  • Quotes are stripped out, and do not separate words («Do»Not»Separate» is parsed as the single word DoNotSeparate);

  • Non-quoted escape characters (e.g. ») preserve the literal value of the next character that follows;

  • Enclosing characters in quotes which are not part of escapedquotes (e.g. «‘») preserve the literal value of all characters within the quotes;

  • Enclosing characters in quotes which are part of escapedquotes (e.g. ‘»‘) preserves the literal value of all characters within the quotes, with the exception of the characters mentioned in escape. The escape characters retain its special meaning only when followed by the quote in use, or the escape character itself. Otherwise the escape character will be considered a normal character.

Examples:

$ printf -- "-o '%s'n" '~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s' > sq.cnf
$ cat sq.cnf
-o '~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s'
$ python -m youtube_dl --get-filename -f 22 --config-location sq.cnf BaW_jenozKc 
/home/df/Documents/2 - Personal/Youtube-DL/youtube-dl test video ''_ä↭𝕐.mp4
$ printf -- '-o "%s"n' '~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s' > dq.cnf
$ cat dq.cnf
-o "~/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s"
$ python -m youtube_dl --get-filename -f 22 --config-location dq.cnf BaW_jenozKc 
/home/df/Documents/2 - Personal/Youtube-DL/youtube-dl test video ''_ä↭𝕐.mp4
$ 

@ritualisticoffee

Thanks for your response.

-o «~/Documents/2 — Personal/Youtube-DL/%(title)s.%(ext)s»
This does also work for me on the command line but I’m unsure why it is having issues parsing the config file.

I hadn’t realised that youtube-dl will look at ~/etc/youtube-dl.conf by default. I thought I was able to set a new default file by using «youtube-dl —config-location ___» but apparently that is just used to point to an alternative config file for an individual download.
So I’ve put youtube-dl.conf in the default location and my issue now is that it seems to be ignoring it. I am at least not having any errors, but it is continuing to download in the default location, ignoring what I have written:

-o '/Users/kaangun/Documents/2 - Personal/Youtube-DL/%(title)s.%(ext)s'

I have since also added «-x» to the end to see if it is ignoring all the commands or just the directory one and it is also ignoring the audio only command.

So the gist of it is that it seems to be ignoring the config file and I’m not sure why. Any ideas?

Also, this is unrelated but possibly interesting/useful to some:
Originally I was saving the file as a .rtf which resulted in an incredibly bizarre issue. I’ve since solved this by making it a plain text document, but for some reason it was giving this error:

ERROR: u'{rtf1ansiansicpg1252cocoartf2636' is not a valid URL. Set --default-search "ytsearch" (or run  youtube-dl "ytsearch:{rtf1ansiansicpg1252cocoartf2636" ) to search YouTube

Which points to a really strange video. Anyway, that’s not an issue anymore. I thought it may be useful to have recorded here if anyone else has similar issues.

@dirkf

From the FM, POSIX-ish case (Windows users should refer to the FM for specifics):

You can configure youtube-dl by placing any supported command line option to a configuration file. On Linux and macOS, the system wide configuration file is located at /etc/youtube-dl.conf and the user wide configuration file at ~/.config/youtube-dl/config. …

Put your personal config in ~/.config/youtube-dl/config, or in a file that you will specify by --config-location .... In the latter case, also include any config that you need from the system-wide or per-user files.

The config loading logic is like this:

    if the command-line has '--config-location ...' then
        load the config
    else if the command-line has '--ignore-config' then
        load no config
    else
        load the system config
        if the loaded config doesn't have '--ignore-config' then
            load the user config

Then the program options are the concatenation of

  • the options in the system-wide config, if loaded
  • the options in the per-user config, if loaded
  • the options in the custom config, if loaded
  • the command-line options.

--config-location ... is only recognised when given in the command-line; --ignore-config is also recognised in the system-wide config. Arguably some more sophisticated nesting logic could be/have been implemented.

Originally I was saving the file as a .rtf which resulted in an incredibly bizarre issue …

Yes, certainly don’t do that. RTF includes formatting codes, a bit like HTML but with and {}. yt-dl will read these as options, giving in this case {rtf1ansiansicpg1252....

@ritualisticoffee

I have now put my config file in both /etc and ~/.config/youtube-dl/config and yet it is still ignoring the command options in the config files.

Just to check I’m understanding how it should work correctly; with a config file in either/both etc or/and ~/.config/youtube-dl/config youtube-dl should read from the config file, apply the command options to the download process. Is that correct?

Currently it seems to be ignoring any config file. I wonder if I am putting it in the wrong place, but I have put it where I think the documentation says I should be putting it, as I am on MacOS.

@dirkf

Just to check I’m understanding how it should work correctly; with a config file in either/both etc or/and ~/.config/youtube-dl/config youtube-dl should read from the config file, apply the command options to the download process.

Yes, with precedence command-line > per-user > system-wide.

The system-wide config is hard-wired as /etc/youtube-dl.conf.

The per-user config is found at the first of these to exist:

  • ${XDG_CONFIG_HOME}/youtube-dl/config, if environment variable XDG_CONFIG_HOME is set
  • ${XDG_CONFIG_HOME}/youtube-dl.config, if environment variable XDG_CONFIG_HOME is set
  • ~/.config/youtube-dl/config, where ~ expands to your home directory
  • ~/.config/youtube-dl.config

In your terminal, use echo "$XDG_CONFIG_HOME" to show that value. Use -v/--verbose to show the config values in the [debug] output.

@ritualisticoffee

I have finally got this working.

My mistake was that I was saving the config file with the incorrect file extension. I did not have finder showing file extensions and thought that youtube-dl.conf was saved with the ‘.conf’ file extension, whereas it was saved as youtube-dl.conf.txt.

I fixed this by, in TextEdit, saving using ‘save as’ and unchecking ‘If no extension is provided, use «.txt».’.

It all seems to be working as intended now. Thanks for your help.

For anyone else on MacOS having difficulties figuring out what to do, follow these steps:

  1. Create a new document within TextEdit (or any other text editing software)
  2. Make sure the document set to be in plain text — in TextEdit you can do this by going to ‘Format’>’Make Plain Text’
  3. Set your preferred commands in the document
  4. ‘File’>’Save As’ and uncheck ‘If no extension is provided, use «.txt».’ (if you don’t see ‘Save As’ under ‘Format’ you can find it by searching the menu bar under ‘Help’)
  5. Save the file as the appropriate name (see below):

a) If you are saving a user-wide config file, you should save it to /Users/YOURUSERNAME/.config/youtube-dl/config where config is the name of the file (this file has no extension) and YOURUSERNAME is your username, you can also use ~/.config/youtube-dl/config as ~ will expand to your home directory.
b) If you are saving a system-wide config file, you should save it to /etc/youtube-dl.conf where youtube-dl.conf is the filename and ‘.conf’ is the file extension.

You can navigate to these file paths in the finder by pressing ‘cmd’+’shift’+’G’ or ‘Go’>’Go to Folder’ from the menu bar.

Note that you probably won’t be able to create files in /etc by default and I had a difficult time finding out how to do that. I instead created the config file elsewhere, named it correctly and then used the terminal to move it to /etc. You can do this by typing sudo cp Path_FROM Path_TO where Path_FROM is the config file where you just created it and Path_TO is /etc.

I hope this is useful for anyone else facing the same, frustrating issue.


Прочитано:
719

Не знаю, как но после довольно продолжительно времени я уже забыл что в моей системе (Ubuntu 12.04.5 Desktop amd64) есть утилита посредством которой я скачиваю онлайн видеофрагаменты для последующего более детального ознакомпления с сайта Youtube. И вот мне понадобилась помощь утилиты youtube-dl для скачивания видео, но в процессе я наткнулся на ошибки в запуске и как оказалось повреждение самого файла в ходе обновления.

Ниже все шаги, что я делал:

ekzorchik@ekzorchik.ru:~$ /usr/bin/youtube-dl

/usr/bin/youtube-dl: строка 1: Not: команда не найдена

ekzorchik@ekzorchik.ru:~$ sudo youtube-dl -U

/usr/bin/youtube-dl: 1: /usr/bin/youtube-dl: Not: not found

ekzorchik@ekzorchik.ru:~$ sudo youtube-dl -U

/usr/bin/youtube-dl: 1: /usr/bin/youtube-dl: Not: not found

ekzorchik@ekzorchik.ru:~$ sudo bash -c "cat /usr/bin/youtube-dl"

Not Found

ekzorchik@ekzorchik.ru:~$

Странно, а почему в исполняемом файле вместо команд лишь строка «Not Found»:

ekzorchik@ekzorchik.ru:~$ ls -l /usr/bin/youtube-dl

-rwxr-xr-x 1 root root 9 дек. 10 11:55 /usr/bin/youtube-dl

ekzorchik@ekzorchik.ru:~$ file /usr/bin/youtube-dl

/usr/bin/youtube-dl: ASCII text, with no line terminators

ekzorchik@ekzorchik.ru:~$ locate youtube-dl

/usr/bin/youtube-dl

/usr/share/doc/youtube-dl

/usr/share/man/man1/youtube-dl.1.gz

/var/lib/dpkg/info/youtube-dl.list

/var/lib/dpkg/info/youtube-dl.md5sums

ekzorchik@ekzorchik.ru:~$ sudo apt-get remove youtube-dl -y

ekzorchik@ekzorchik.ru:~$ sudo updatedb

ekzorchik@ekzorchik.ru:~$ locate youtube-dl

Отлично в системе больше не осталось какого либо упоминания об утилите youtube-dl

ekzorchik@ekzorchik.ru:~$ sudo apt-get install youtube-dl -y

, а вот когда переустановил то и исполняемый файл стал больше размером и внутри появились исполняемые инструкции:

ekzorchik@ekzorchik.ru:~$ ls -l /usr/bin/youtube-dl && tail /usr/bin/youtube-dl | head -n 5

-rwxr-xr-x 1 root root 159879 мая 17 2013 /usr/bin/youtube-dl

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’)

ekzorchik@ekzorchik.ru:~$ md5sum /usr/bin/youtube-dl

43678cad6a1b4ff3330c2fada3206894 /usr/bin/youtube-dl

Запускаю обновление утилиты:

ekzorchik@ekzorchik.ru:~$ sudo youtube-dl -U

Updating to latest version…

Updated youtube-dl. Restart youtube-dl to use the new version.

ekzorchik@ekzorchik.ru:~$ youtube-dl

/usr/bin/youtube-dl: строка 1: Not: команда не найдена

ekzorchik@ekzorchik.ru:~$ md5sum /usr/bin/youtube-dl

9d1ead73e678fa2f51a70a933b0bf017 /usr/bin/youtube-dl

и вот оно что, в процессе обновления исполняемый файл повреждается и его содержимое представляет из себя лишь строку «Not Found»

Мне нужно скачать один видеофрагмент с сайта Youtube:

ekzorchik@ekzorchik.ru:~$ youtube-dl -t https://www.youtube.com/watch?feature=player_embedded&v=2G--OARGaLk

[1] 13769

eekzorchik@ekzorchik.ru:~$ ERROR: Did you forget to quote the URL? Remember that & is a meta character in most shells, so you want to put the URL in quotes, like youtube-dl «http://www.youtube.com/watch?feature=foo&v=BaW_jenozKc» or simply youtube-dl BaW_jenozKc .

^C

[1]+ Exit 1 youtube-dl -t https://www.youtube.com/watch?feature=player_embedded

Параметр

-t, —title

Use the title of the video in the file name used to download the video.

Скачиваю видео передав утилиту лишь его название, а не полный URL как я делал это раньше:

ekzorchik@ekzorchik.ru:~$ youtube-dl -t 2G--OARGaLk

[youtube] Setting language

[youtube] 2G—OARGaLk: Downloading webpage

[youtube] 2G—OARGaLk: Downloading video info webpage

[youtube] 2G—OARGaLk: Extracting video information

[download] Destination: ZeXtras Suite Installation Tutorial 2013-2G—OARGaLk.mp4

[download] 100% of 21.80MiB in 00:12

И судя по отчету видеофрагмент успешно скачался что мне собственно и требовалось. Хочу еще раз повториться, как важно до всего доходить самим, собственный опыт еще никто не отменял. А этой мини заметкой я хочу лишний раз себе напомнить об этом. На этом собственно и всё, с уважением автор блога — ekzorchik.


Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

Понравилась статья? Поделить с друзьями:
  • Error fix gmod
  • Error fix folder 0xc000007b
  • Error fix 4 8 торрент
  • Error first argument to readability constructor should be a document object
  • Error firewalld is active please use firewall cmd