#!/usr/bin/python # -*- coding: utf-8 -*- # # Hooks script for gPodder to convert id3 version 2 to id3 version 1 # because some devices do not support version 2 # # Version 1.0 - Rodolfo García Peñas (kix) # To use, copy it as a Python script into ~/.config/gpodder/hooks/id3v2toid3v1.py # # Dependencies: # * This script needs the eyeD3 command in the $PATH # In debian is included in the package eyed3 # # This script 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 2 of the License, or # (at your option) any later version. # # gPodder 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 . import gpodder import subprocess import os from gpodder.liblogger import log def id3v2toid3v1(from_file, to_file): try: command = 'eyeD3 --to-v1.1 "%s"' % (to_file) log("id3v2toid3v1: Executing %s", command) p = subprocess.Popen(command, shell=True) # retcode[1] values: # <0: error | 0: success retcode = os.waitpid(p.pid, 0) log("id3v2toid3v1: Child with pid %s returned %s", retcode[0], retcode[1]) except OSError, e: log("id3v2toid3v1: Execution failed: %s", e) class gPodderHooks(object): def __init__(self): log('id3v2toid3v1 extension: Initializing.') def on_file_copied_to_filesystem(self, mp3playerdevice, from_file, to_file): log('id3v2toid3v1: on_file_copied_to_filesystem(%s, %s)' % (from_file, to_file)) id3v2toid3v1(from_file, to_file)