dmcg wrote:I'd certainly be very interested, thank you, although I suspect that I would end up running on 2 different machines.
At the end of this post is an example of a custom user command script that could be used to add get_iplayer downloads to iTunes as podcasts. It's from an early experiment so it doesn't cover all the metadata issues you run into when moving get_iplayer downloads to iTunes. It just writes the ID3 frames/MP4 atoms for podcasts (according to iTunes) and then adds the file to iTunes, relying on get_iplayer to fill in most of the metadata with id3v2 or AtomicParsley.
The downloaded files appear in iTunes as podcasts grouped by album. TV shows usually come out of get_iplayer without the album atom set, thus the inclusion of a hack to copy show name to album name for MP4 files. The resulting podcasts have no feed URLs, thus a "subscription" disappears when you remove all its episodes.
The example script needs Python, Mutagen, and Appscript (thus OSX). I would guess the iTunes COM interfaces can be used in Windows. Regardless of the toolset employed, these are the basics: PCST and TGID ID3 frames (pcst and egid MP4 atoms) appear to be absolutely required and the TDRL ID3 frame (\xa9day MP4 atom) is necessary for episode sorting. The description frames/atoms aren't necessary, but make for a nicer default iTunes podcast listing.
If you want to apply this script to every get_iplayer download, you can add the following to your options file:
-
Code: Select all
command /path/to/add_itunes_podcast_episode.py "<filename>" "<pid>" "<firstbcast>" "<descshort>" "<desc>"
Example script:
-
Code: Select all
#!/usr/bin/env python
import sys
import os
from appscript import *
import mutagen.id3
from mutagen.id3 import ID3, TDRL, TIT3
from mutagen.mp4 import MP4
class PCST(mutagen.id3.TextFrame): "Podcast Flag"
class TGID(mutagen.id3.TextFrame): "Podcast GID"
class TDES(mutagen.id3.TextFrame): "Podcast Description"
PODCAST_FRAMES = dict()
PODCAST_FRAMES["PCST"] = PCST
PODCAST_FRAMES["TGID"] = TGID
PODCAST_FRAMES["TDES"] = TDES
mutagen.id3.Frames.update(PODCAST_FRAMES)
def add_itunes_podcast_episode(argv):
filename, pid, firstbcast, descshort, desc = argv[1:]
ext = os.path.splitext(filename)[1].lower()[1:]
if ext == "mp3":
add_itunes_podcast_episode_mp3(filename, pid, firstbcast, descshort, desc)
elif ext == "mp4":
add_itunes_podcast_episode_mp4(filename, pid, firstbcast, descshort, desc)
def add_itunes_podcast_episode_mp3(filename, pid, firstbcast, descshort, desc):
tag = ID3(filename)
tag['PCST'] = PCST(3, u"\x00")
tag['TGID'] = TGID(3, pid)
tag['TDRL'] = TDRL(3, firstbcast)
tag['TIT3'] = TIT3(3, descshort)
tag['TDES'] = TDES(3, desc)
tag.save()
itunes = app('iTunes')
track = itunes.add(mactypes.File(filename))
print "INFO: added iTunes podcast episode: {0} / {1} / {2}".format(track.artist(), track.album(), track.name())
def add_itunes_podcast_episode_mp4(filename, pid, firstbcast, descshort, desc):
tag = MP4(filename)
tag['pcst'] = True
tag['egid'] = pid
tag['\xa9alb'] = tag['tvsh'] # assume video and force album = show for podcast
tag['\xa9day'] = firstbcast # probably already exists in file, but force anyway
tag['desc'] = descshort # probably already exists in file, but force anyway
tag['ldes'] = desc
tag.save()
itunes = app('iTunes')
track = itunes.add(mactypes.File(filename))
print "INFO: added iTunes podcast episode: {0} / {1} / {2}".format(track.artist(), track.album(), track.name())
if __name__ == "__main__":
if len(sys.argv) == 6:
add_itunes_podcast_episode(sys.argv)
else:
print "ERROR: cannot add iTunes podcast episode: missing arguments"