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

--xattrs does not work on OS X. #9054

Closed
danfiscus opened this issue Apr 1, 2016 · 21 comments
Closed

--xattrs does not work on OS X. #9054

danfiscus opened this issue Apr 1, 2016 · 21 comments
Labels
bug

Comments

@danfiscus
Copy link

@danfiscus danfiscus commented Apr 1, 2016

  • I've verified and I assure that I'm running youtube-dl 2016.04.01

Before submitting an issue make sure you have:

  • At least skimmed through README and most notably FAQ and BUGS sections
  • 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)
  • Question
  • Other

If the purpose of this issue is a bug report, site support request or you are not completely sure provide the full verbose output as follows:

Add -v flag to your command line you run youtube-dl with, copy the whole output and insert it here. It should look similar to one below (replace it with your log inserted between triple ```):

$ youtube-dl --write-auto-sub --sub-format srt --include-ads --console-title --newline --embed-subs --xattrs --add-metadata -v https://www.youtube.com/watch?v=Bfktt22nUG4
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'--write-auto-sub', u'--sub-format', u'srt', u'--include-ads', u'--console-title', u'--newline', u'--embed-subs', u'--xattrs', u'--add-metadata', u'-v', u'https://www.youtube.com/watch?v=Bfktt22nUG4']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2016.04.01
[debug] Python version 2.7.10 - Darwin-14.5.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 2.7.1, ffprobe 2.7.1
[debug] Proxy map: {}
[youtube] Bfktt22nUG4: Downloading webpage
[youtube] Bfktt22nUG4: Downloading video info webpage
[youtube] Bfktt22nUG4: Extracting video information
[youtube] Bfktt22nUG4: Looking for automatic captions
[youtube] Bfktt22nUG4: Downloading MPD manifest
WARNING: No subtitle format found matching "srt" for language en, using vtt
[info] Writing video subtitles to: iPhone SE (parody)-Bfktt22nUG4.en.vtt
WARNING: Requested formats are incompatible for merge and will be merged into mkv.
[download] iPhone SE (parody)-Bfktt22nUG4.mkv has already been downloaded and merged
[ffmpeg] Adding metadata to 'iPhone SE (parody)-Bfktt22nUG4.mkv'
[debug] ffmpeg command line: ffmpeg -y -i 'file:iPhone SE (parody)-Bfktt22nUG4.mkv' -c copy -metadata 'comment=Previous sketch: https://www.youtube.com/watch?v=--Fg3YbwG8E&index=1&list=PLiWL8lZPZ2_kafFTewyr06GuSPFd0m8hf

Help me make fun of everything! http://bit.ly/1A0Crdb
TWITTER: http://www.twitter.com/jacksfilms
FACEBOOK: http://www.facebook.com/jacksfilmsfans
LIVE CHAT every FRIDAY: http://www.younow.com/jacksfilms
SNAPCHAT: realjacksfilms
MERCH: http://www.jacksfilms.spreadshirt.com
PERISCOPE: http://www.periscope.tv/jacksfilms' -metadata 'description=Previous sketch: https://www.youtube.com/watch?v=--Fg3YbwG8E&index=1&list=PLiWL8lZPZ2_kafFTewyr06GuSPFd0m8hf

Help me make fun of everything! http://bit.ly/1A0Crdb
TWITTER: http://www.twitter.com/jacksfilms
FACEBOOK: http://www.facebook.com/jacksfilmsfans
LIVE CHAT every FRIDAY: http://www.younow.com/jacksfilms
SNAPCHAT: realjacksfilms
MERCH: http://www.jacksfilms.spreadshirt.com
PERISCOPE: http://www.periscope.tv/jacksfilms' -metadata artist=jacksfilms -metadata 'title=iPhone SE (parody)' -metadata date=20160321 -metadata 'purl=https://www.youtube.com/watch?v=Bfktt22nUG4' 'file:iPhone SE (parody)-Bfktt22nUG4.temp.mkv'
[ffmpeg] Embedding subtitles in 'iPhone SE (parody)-Bfktt22nUG4.mkv'
[debug] ffmpeg command line: ffmpeg -y -i 'file:iPhone SE (parody)-Bfktt22nUG4.mkv' -i 'file:iPhone SE (parody)-Bfktt22nUG4.en.vtt' -map 0 -c copy -map -0:s -map 1:0 -metadata:s:s:0 language=eng 'file:iPhone SE (parody)-Bfktt22nUG4.temp.mkv'
Deleting original file iPhone SE (parody)-Bfktt22nUG4.en.vtt (pass -k to keep)
[metadata] Writing metadata to file's xattrs
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/bin/youtube-dl/__main__.py", line 19, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 419, in main
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 409, in _real_main
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1725, in download
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 680, in extract_info
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 725, in process_ie_result
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1371, in process_video_result
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1707, in process_info
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1771, in post_process
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/xattrpp.py", line 158, in run
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/xattrpp.py", line 72, in write_xattr
AttributeError: 'module' object has no attribute 'set'

Description of your issue, suggested solution and other information

I attempted to download a video and I wanted to use the -xattrs flag, but the above error came up. The file does not appear on my computer. I do not know what other description or information to provide, if any, but if you need me to supply more information I will do my best to do so.

@danfiscus danfiscus changed the title `--xattrs` does not work on OS X. --xattrs does not work on OS X. Apr 1, 2016
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Apr 2, 2016

How did you install pyxattr and what's your pyxattr's version?

@danfiscus
Copy link
Author

@danfiscus danfiscus commented Apr 3, 2016

@yan12125 I don't remember installing it myself. It must have come with another package at some point in time. How do I check the version?

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Apr 5, 2016

Run the following command:

$ python -c 'import xattr; print(xattr.__version__)'
@danfiscus
Copy link
Author

@danfiscus danfiscus commented Apr 5, 2016

@yan12125 I have version 0.6.4

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Apr 5, 2016

I guess you have installed dxpy via homebrew? [1] It ships with xattr 0.6.4 [2], which is different from pyxattr [3], and currently only the latter is supported by youtube-dl. [2] claims to support both Linux and Mac OS X explicitly while [3] says only Linux supported. youtube-dl should add support for [2].

[1] https://github.com/Homebrew/homebrew-core/blob/master/Formula/dxpy.rb
[2] https://github.com/xattr/xattr
[3] https://github.com/iustin/pyxattr

@yan12125 yan12125 closed this Apr 5, 2016
@yan12125 yan12125 reopened this Apr 5, 2016
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Apr 5, 2016

Sorry mis-clicking.

@wilx
Copy link

@wilx wilx commented Jun 7, 2016

I can see this issue on Linux as well.

[metadata] Writing metadata to file's xattrs
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/bin/youtube-dl/__main__.py", line 19, in <module>
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 419, in main
  File "/usr/local/bin/youtube-dl/youtube_dl/__init__.py", line 409, in _real_main
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1730, in download
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 682, in extract_info
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 727, in process_ie_result
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1376, in process_video_result
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1712, in process_info
  File "/usr/local/bin/youtube-dl/youtube_dl/YoutubeDL.py", line 1776, in post_process
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/xattrpp.py", line 158, in run
  File "/usr/local/bin/youtube-dl/youtube_dl/postprocessor/xattrpp.py", line 72, in write_xattr
AttributeError: 'module' object has no attribute 'set'

~/Downloads> youtube-dl --version
2016.04.13
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jun 7, 2016

@wilx Post the output of the following command:

python -c 'import xattr; print(xattr); print(xattr.__version__)'
@wilx
Copy link

@wilx wilx commented Jun 7, 2016

@yan12125 Here:

> python -c 'import xattr; print(xattr); print(xattr.__version__)'
<module 'xattr' from '/usr/lib/python2.7/dist-packages/xattr/__init__.pyc'>
0.7.8

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jun 7, 2016

You are using xattr [1]. Remove it and install pyxattr [2]. The two are similar but have different APIs.

[1] https://github.com/xattr/xattr
[2] https://github.com/iustin/pyxattr

@wilx
Copy link

@wilx wilx commented Jun 7, 2016

OK, this does fix the issue for me.

@Saklad5
Copy link

@Saklad5 Saklad5 commented Sep 19, 2016

How do you install pyxattr on OS X?

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 24, 2016

pyxattr does not support OS X. youtube-dl should support both xattr and pyxattr. I'll try to implement it.

@yan12125 yan12125 added the bug label Sep 24, 2016
@Saklad5
Copy link

@Saklad5 Saklad5 commented Sep 26, 2016

OK, I tried fixing this myself. I think something in ffmpeg is removing attributes, but that's just a wild guess. I can post the code I put together for assigning the metadata in the xattrs post processor, if anyone is interested in stepping in where I gave up.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 26, 2016

I can post the code I put together for assigning the metadata in the xattrs post processor

@Saklad5 It would be great.

@Saklad5
Copy link

@Saklad5 Saklad5 commented Sep 26, 2016

    `try:
        xattr_mapping = {
            'user.xdg.referrer.url': 'webpage_url',
            # 'user.xdg.comment':            'description',
            'user.dublincore.title': 'title',
            'user.dublincore.date': 'upload_date',
            'user.dublincore.description': 'description',
            'user.dublincore.contributor': 'uploader',
            'user.dublincore.format': 'format',
        }
        if sys.platform == ('darwin'):
            xattr_mapping = {
                'public.movie:kMDItemIdentifier': 'id',
                'public.movie:kMDItemPublishers': 'uploader',
                'public.movie:kMDItemContentCreationDate': 'upload_date',
                'public.movie:kMDItemRights': 'license',
                'public.movie:kMDItemAuthors': 'creator',
                'public.movie:kMDItemTitle': 'title',
                'public.movie:kMDItemDescription': 'description',
                #'public.movie:kMDItemKeywords': 'tags',
                'public.movie:kMDItemDurationSeconds': 'duration',
                'public.movie:kMDItemAudiences': 'age_limit',
                'public.movie:kMDItemWhereFroms': 'webpage_url',
                'public.movie:kMDItemStarRating': 'average_rating',
            }
        for xattrname, infoname in xattr_mapping.items():

            value = info.get(infoname)

            if value:
                if infoname == 'upload_date':
                    value = hyphenate_date(value)
                if type(value) is not str:
                    value = unicode(value)
                byte_value = value.encode('utf-8')
                write_xattr(filename, xattrname, byte_value)

        return [], info`
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 26, 2016

Could you paste your command too?

@Saklad5
Copy link

@Saklad5 Saklad5 commented Sep 26, 2016

What command? I just modified youtube-dl/postprocessor/xattrspp.py to check the system platform and add additional metadata if it was macOS.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Sep 26, 2016

In a previous post, you've mentioned that ffmpeg inteferes with --xattrs. It would be better to have an example to see how things are not working.

@Saklad5
Copy link

@Saklad5 Saklad5 commented Sep 29, 2016

I noticed that the metadata seemed to be applied to the video file after being downloaded, but it wasn’t present after being merged with the audio file. “mdls” didn’t even show any of the Dublin Core attributes.

@yan12125 yan12125 closed this in 53a7e3d Oct 1, 2016
@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Oct 1, 2016

This will be fixed in the next version. I've just tested it on Sierra.

@Saklad5 Adding more xattr fields for Mac is discussed in #8089. Please move there.

yan12125 added a commit that referenced this issue Oct 1, 2016
Reported at
#9054 (comment)
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
4 participants
You can’t perform that action at this time.