【问题标题】:kid3-cli set picture does not set album photo for mp3Kid3-cli设置图片不设置mp3的专辑照片
【发布时间】:2022-11-11 02:25:21
【问题描述】:

几个小时以来,我一直在尝试以编程方式在 mp3 文件中设置专辑封面图像。

(我使用的是运行 Monterey 12.3.1 的 Mac)

使用 Kid3-cli,我可以使用以下命令设置所有其他元数据:

kid3-cli -c "set artist 'Artist Name'" -c "set album 'Album Name'" -c "set title 'Song Title'" /Path/to/my/audio.mp3

我已经用set picture 和所有其他元数据更新扩展了这个命令,但是在finder 中没有显示音频文件的照片。

使用此命令:

kid3-cli -c "set artist 'Artist Name'" \
         -c "set album 'Album Name'" \
         -c "set title 'Title'" \
         -c "set albumart 'URL for album art'" \
         -c "set picture: '/Path/to/picture' ''" \
         "/path/to/mp3/file.mp3"

我已经按照这里的文档:Kid3 Documentation 并尝试过 运行命令的一些变体来设置图片希望一个可以工作。

这些是我用来尝试显示图像的命令变体。

 // with semicolon after command
 kid3-cli -c "set picture: '/Path/to/picture' ''" "/Path/to/my/audio.mp3"
 // without semicolon
 kid3-cli -c "set picture '/Path/to/picture' ''" "/Path/to/my/audio.mp3" 
 // swapping single/double quotes
 kid3-cli -c 'set picture: "/path/to/picture" ""' "/path/to/my/audio.mp3"

有趣的是,当我运行 Kid3 cli 并输入 get 时,它会打印出元数据并将其显示为图片:

 *Picture: Cover (front) /path/to/my/picture/thumb.jpg

但根据文档,它应该在调用set picture 时设置实际的图像数据,而不是图片的路径。

我错过了什么吗?

【问题讨论】:

    标签: bash metadata mp3 id3v2 kid3-cli


    【解决方案1】:

    当我不小心解决了这个问题时,我正用头撞墙试图让这个自己工作。
    你需要做的就是改变这个:
    kid3-cli -c "set picture:'/path/to/image' ''" /path/to/file.opus
    对此:
    kid3-cli -c "set Picture:'/path/to/image' ''" /path/to/file.opus
    你需要做的就是大写“图片”中的字母“P”。
    在 Arch 上测试。

    【讨论】:

    • 谢谢你的评论。我进行了实验,它是否大写对我来说似乎并不重要。我编写了一个 bash 脚本,我为要更新的每个音乐文件调用它,并且在脚本中我将传入的路径参数解析为一个变量,然后在我的命令中使用该变量。我的错误是我没有将变量括在单引号中。我将使用我现在使用的脚本添加一个答案。
    【解决方案2】:

    我失败的原因是一个简单的错误。

    我有一个 bash 脚本,我从另一个(Mac)应用程序调用它,我将参数传递给该脚本,该脚本处理调用 Kid3-cli 并将参数传递给它。

    这是我的脚本不起作用(只有“设置图片:”不起作用,所有其他元数据都已设置)。

    #!/bin/sh
    
    # Arguments this script expects when called:
    # $0 - script name (mp3_update) (passed in by default)
    # $1 - mp3 file path
    # $2 - artist
    # $3 - album
    # $4 - title
    # $5 - album art url
    # $6 - new file path (renamed and move to this path)
    # $7 - cache image path (path to image thumbnail stored locally)
    
    #ARTIST="$(echo "$uat_catalog$line" | sed -e 's/[()&]/\&/g')" // this is to sanitize vars in []
    #escape any single quotes in the paths
    CURRENT_PATH=${1//'/'}
    NEW_PATH=${6//'/'}
    LOCAL_IMAGE_CACHE=${7//'/'}
    
    /Applications/kid3.app/Contents/MacOS/kid3-cli -c "set artist '${2//'/'}'" 
         -c "set album '${3//'/'}'" 
         -c "set title '${4//'/'}'" 
         -c "set albumart '${5//'/'}'" 
         -c "set picture: $LOCAL_IMAGE_CACHE ''" 
         "$CURRENT_PATH"
    
    # move file to new home
    mv "$CURRENT_PATH" "$NEW_PATH"
    

    如果您仔细查看“设置图片:”命令,您会注意到 $LOCAL_IMAGE_CACHE 变量未包含在单引号中。

    省略引号会导致设置 url 而不是实际的图像数据。

    这是我现在正在运行的脚本版本:

    #!/bin/sh
    
    # Arguments this script expects when called:
    # $0 - script name (mp3_update) (passed in by default)
    # $1 - mp3 file path
    # $2 - artist
    # $3 - album
    # $4 - title
    # $5 - album art url
    # $6 - new file path (renamed and move to this path)
    # $7 - cache image path (path to image thumbnail stored locally)
    
    #ARTIST="$(echo "$uat_catalog$line" | sed -e 's/[()&]/\&/g')" // this is to sanitize vars in []
    #escape any single quotes in the paths
    CURRENT_PATH=${1//'/'}
    NEW_PATH=${6//'/'}
    LOCAL_IMAGE_CACHE=${7//'/'}
    
    /Applications/kid3.app/Contents/MacOS/kid3-cli -c "set artist '${2//'/'}'" 
         -c "set album '${3//'/'}'" 
         -c "set title '${4//'/'}'" 
         -c "set albumart '${5//'/'}'" 
         -c "set picture:'$LOCAL_IMAGE_CACHE' 'Album Art'" 
         "$CURRENT_PATH"
    
    # move file to new home
    mv "$CURRENT_PATH" "$NEW_PATH"
    

    【讨论】:

      猜你喜欢
      • 2023-03-27
      • 2010-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-05
      • 2014-06-06
      • 1970-01-01
      • 2018-07-02
      相关资源
      最近更新 更多