Skip to content

Instantly share code, notes, and snippets.

@cbednarski
Created February 3, 2016 00:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbednarski/2e0e9616d8dc6e66e60b to your computer and use it in GitHub Desktop.
Save cbednarski/2e0e9616d8dc6e66e60b to your computer and use it in GitHub Desktop.
di.fm iTunes playlist importer
import re
"""
di.fm allows you to download a playlist of all your favorite channels. For some
reason when you open this playlist with iTunes only one of the channels is
added. This script splits the playlist file into many playlist files so you can
easily load all of your favorites into iTunes and enjoy di.fm streaming without
running Flash in your browser.
"""
items = open("di.pls").read().split("File")
for item in items:
title_ = re.compile("Title\d+=(.+)").findall(item)
if len(title_) != 1:
continue
filename = title_[0].strip() + ".pls"
body = "[playlist]\nNumberOfEntries=1\nFile" + item
open(filename, mode="w").write(body)
@href
Copy link

href commented Jun 2, 2017

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment