Mirror of the Rel4tion website/wiki source, view at <http://rel4tion.org>

[[ 🗃 ^yEzqv rel4tion-wiki ]] :: [📥 Inbox] [📤 Outbox] [🐤 Followers] [🤝 Collaborators] [🛠 Commits]

Clone

HTTPS: git clone https://vervis.peers.community/repos/yEzqv

SSH: git clone USERNAME@vervis.peers.community:yEzqv

Branches

Tags

master :: people / fr33domlover /

delpic.py

#!/usr/bin/python
# -*- coding: utf-8 -*-

# delpic.py - Ogg album art remover
# Copyright (C) 2014 - fr33domlover <fr33domlover@riseup.net>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

# [[!meta description="Ogg embedded album art mass-remover"]]
# [[!tag /scripts]]

#--------------------------------- how to use ---------------------------------
# Usage:
#     ./delpic.py <dir>
#
# This program takes a folder name, and traverses the whole file tree under that
# folder, i.e. all the files inside and files inside its subfolders and so on.
# For each Ogg file it finds, it removes the album art tag if it is present.
#
# HOW TO IMPROVE: Implement mass-removal of album art in command-line and in
# graphical tag editors (which is trivial, as the length of this script
# implies), so that this script is not needed.
#------------------------------------------------------------------------------

import mutagen
import os
import sys

file_list = []
root_dir = sys.argv[1]
file_count = 0
ogg_file_count = 0
ogg_update_count = 0

for root, sub_folders, files in os.walk (root_dir):
    for file in files:
        f = os.path.join (root, file)
        filename, file_extension = os.path.splitext (f)
        file_count += 1
        if file_extension == ".ogg":
            ogg_file_count += 1
            t = mutagen.File (f)
            try:
                t.pop ('metadata_block_picture')
                t.save ()
                ogg_update_count += 1
            except KeyError:
                pass

print "Files found: ", file_count
print "Ogg files found: ", ogg_file_count
print "Ogg files updated: ", ogg_update_count

[See repo JSON]