Skip to content

Instantly share code, notes, and snippets.

@pgriess
pgriess / demo.py
Created December 19, 2011 01:12
Script to stream audio from Rdio
#!/bin/env python
#
# Demo tool to generate the rtmpdump(1) command for streaming a song from Rdio.
import httplib
from optparse import OptionParser
from os.path import basename
from pprint import pprint
from pyamf.remoting.client import RemotingService
from rdioapi import Rdio
@mpapi
mpapi / cached.py
Created May 1, 2011 22:05
cached: Python contextmanager for cached URL fetches
from contextlib import closing, contextmanager
from urllib2 import urlopen
import hashlib
import os
import time
@contextmanager
def cached(url, expires=0, root='/tmp'):
'''
Returns the contents of the URL through a file-based cache. If "expires" is