Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embedding thumbnail raise key error 'filename' #10185

Closed
gigalala opened this issue Jul 29, 2016 · 7 comments
Closed

Embedding thumbnail raise key error 'filename' #10185

gigalala opened this issue Jul 29, 2016 · 7 comments

Comments

@gigalala
Copy link

@gigalala gigalala commented Jul 29, 2016

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like that [x])
  • Use Preview tab to see how your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2016.07.28. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.

  • [x ] I've verified and I assure that I'm running youtube-dl 2016.07.28

Before submitting an issue make sure you have:

  • [x ] At least skimmed through README and most notably FAQ and BUGS sections
  • [ x] Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • [x ] Question
  • Other

Hi,
I am trying to use the embed thumbnail option on python script, here are my ydl options:

        ydl_opts = {
            'format': 'bestaudio/best',
            'download_archive': self.songs_data,
            'outtmpl': '/'+download_path+'/'+'%(title)s.%(ext)s',
            'progress_hooks': [self.my_hook],
            'postprocessors': [
                {'key': 'EmbedThumbnail',},
                {'key': 'FFmpegExtractAudio',
                'preferredcodec': 'mp3',
                'preferredquality': '192'},]}

But i get the following error:

line 29, in start_download
    ydl.download([download_list])
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 1775, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 693, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 854, in process_ie_result
    extra_info=extra)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 746, in process_ie_result
    extra_info=extra_info)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 693, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 739, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 1421, in process_video_result
    self.process_info(new_info)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 1757, in process_info
    self.post_process(filename, info_dict)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 1821, in post_process
    files_to_delete, info = pp.run(info)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/postprocessor/embedthumbnail.py", line 36, in run
    thumbnail_filename = info['thumbnails'][-1]['filename']
KeyError: 'filename'
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jul 29, 2016

Please post the whole script so that we can test it. And please also add 'verbose': True, to ydl_opts so that verbose information is also printed out.

@gigalala
Copy link
Author

@gigalala gigalala commented Jul 29, 2016

verbose:

[debug] Encodings: locale US-ASCII, fs utf-8, out us-ascii, pref US-ASCII
[debug] youtube-dl version 2016.07.28
[debug] Python version 3.4.1 - Darwin-15.3.0-x86_64-i386-64bit
[debug] exe versions: avconv 11.4, avprobe 11.4, ffmpeg 3.0.2, ffprobe 3.0.2
[debug] Proxy map: {}
download] Downloading video 13 of 14
[youtube] WZM4iXT3-ic: Downloading webpage
[youtube] WZM4iXT3-ic: Downloading video info webpage
[youtube] WZM4iXT3-ic: Extracting video information
[youtube] {43} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {18} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {36} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {17} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {135} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {244} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {134} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {243} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {133} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {242} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {160} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {278} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {140} signature length 42.43, html5 player en_US-vflVo2R8O
[youtube] {171} signature length 42.43, html5 player en_US-vflVo2R8O
[debug] Invoking downloader on 'https://r15---sn-bvvbax-2ime.googlevideo.com/videoplayback?gir=yes&initcwndbps=2502500&expire=1469822795&mime=audio%2Fwebm&itag=171&nh=EAI&fexp=9416891%2C9419452%2C9422596%2C9428398%2C9429856%2C9431012%2C9433096%2C9433221%2C9433946%2C9435036%2C9435526%2C9435666%2C9435876%2C9437066%2C9437258%2C9437552%2C9438327%2C9438662%2C9438805%2C9439581%2C9439652%2C9439889%2C9440376%2C9440435%2C9440880%2C9441119%2C9441450%2C9441593%2C9442074%2C9442242%2C9442424&ipbits=0&ei=62KbV4j8H8bN-wO5s6yoCg&dur=239.193&sparams=clen%2Cdur%2Cei%2Cgir%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Ckeepalive%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Crequiressl%2Csource%2Cupn%2Cexpire&requiressl=yes&mv=m&pl=17&mt=1469800475&ms=au&id=o-ABq8IOxwkMHSy1tTfsOM0SqteEPHeGkk_AQwbpRtqhRV&ip=68.104.199.46&key=yt6&keepalive=yes&mn=sn-bvvbax-2ime&mm=31&source=youtube&sver=3&clen=3565919&upn=K5Ys10SD-FA&lmt=1396634731717119&signature=6C75142D383770A1ACA965568B18D9036446B242.C30BF88A850786FFD8EE4C3CCA6A86C90685B541&ratebypass=yes'
[download] Destination: //Users/Avihai/Music/iTunes/iTunes Media/Automatically Add to iTunes/אריק איינשטיין עטור מצחך זהב שחור Arik Einstein.webm
[K[download] 100% of 3.40MiB in 00:05
Done downloading אריק איינשטיין עטור מצחך זהב שחור Arik Einstein.webm
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/Avihai/Desktop/Avihai/DEV/YoutubeDownloader/YoutubeDownload.py", line 29, in start_download
    ydl.download([download_list])
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 1775, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 693, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 854, in process_ie_result
    extra_info=extra)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 746, in process_ie_result
    extra_info=extra_info)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 693, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 739, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 1421, in process_video_result
    self.process_info(new_info)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 1757, in process_info
    self.post_process(filename, info_dict)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/YoutubeDL.py", line 1821, in post_process
    files_to_delete, info = pp.run(info)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/youtube_dl/postprocessor/embedthumbnail.py", line 36, in run
    thumbnail_filename = info['thumbnails'][-1]['filename']
KeyError: 'filename'

script:

from __future__ import unicode_literals
import youtube_dl
import os


class YoutubeDownload:

    def __init__(self, progress):
        os.environ["PATH"] += os.pathsep + "/usr/local/bin"
        self.songs_data = "songs_data.txt"
        self.progress = progress


    def start_download(self,download_path, download_list):

        ydl_opts = {
            'verbose': True,
            'format': 'bestaudio/best',
            'download_archive': self.songs_data,
            'outtmpl': '/'+download_path+'/'+'%(title)s.%(ext)s',
            'progress_hooks': [self.my_hook],
            'postprocessors': [
                {'key': 'EmbedThumbnail',},
                {'key': 'FFmpegExtractAudio',
                'preferredcodec': 'mp3',
                'preferredquality': '192'},]}

        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            ydl.download([download_list])
        self.progress.put(True)

    def my_hook(self,d):
        if d['status'] == 'finished':
            file_tuple = os.path.split(os.path.abspath(d['filename']))
            print("Done downloading {}".format(file_tuple[1]))
            self.progress.put("Done downloading {}".format(file_tuple[1]))
        if d['status'] == 'downloading':
            print(d['filename'], d['_percent_str'], d['_eta_str'])
            self.progress.put(d['filename'], d['_percent_str'], d['_eta_str'])
@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jul 29, 2016

'writethumbnail': True must be added to options.

@dstftw dstftw closed this Jul 29, 2016
@gigalala
Copy link
Author

@gigalala gigalala commented Jul 29, 2016

Now i am getting this:
youtube_dl.utils.DownloadError: �[0;31mERROR:�[0m Only mp3 and m4a/mp4 are supported for thumbnail embedding for now.

script:

        ydl_opts = {
            'writethumbnail': True,
            'format': 'bestaudio/best',
            'download_archive': self.songs_data,
            'outtmpl': '/'+download_path+'/'+'%(title)s.%(ext)s',
            'progress_hooks': [self.my_hook],
            'postprocessors': [
                {'key': 'EmbedThumbnail',},
                {'key': 'FFmpegExtractAudio',
                'preferredcodec': 'mp3',
                'preferredquality': '192'},]}
@gigalala
Copy link
Author

@gigalala gigalala commented Jul 29, 2016

Seems like it tries to add the thumbnail before the file is converted to mp3

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Jul 29, 2016

Because you've requested it to do so. Change the order of post processors.

@gigalala
Copy link
Author

@gigalala gigalala commented Jul 29, 2016

Now it can't find the jpg file, although it exist:
youtube_dl.utils.DownloadError: �[0;31mERROR:�[0m file://Users/Avihai/Music/iTunes/iTunes Media/Automatically Add to iTunes/Coldplay - Fix You [HD].jpg: No such file or directory


        ydl_opts = {
            'writethumbnail': True,
            'format': 'bestaudio/best',
            'download_archive': self.songs_data,
            'outtmpl': '/'+download_path+'/'+'%(title)s.%(ext)s',
            'progress_hooks': [self.my_hook],
            'postprocessors': [
                {'key': 'FFmpegExtractAudio',
                'preferredcodec': 'mp3',
                'preferredquality': '192'},
                {'key': 'EmbedThumbnail',},]}

thanks for the help

@dstftw dstftw mentioned this issue Aug 23, 2016
1 of 5 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.