Jump to content

here is a python script (linux) for ripping pandora


watson540

Recommended Posts

i found this on the net, and now i cannot found where i got it to give proper credit, but i didnt see it here

i want to make clear that i DID NOT make this, and I only post it in the hopes someone might improve it a tad..such as adding the mp4 extension to the files when they get moved and etc.

at the moment it just locks the files in /tmp so flash cant remove them, then it moves it into a folder inside your home named pandora

hopefully a python guru will come along and perfect this as it takes no tricks or flash switching to run

it wont let me upload so i guess ill post it here

--------------------start under here-----------------------------

#!/usr/bin/pythonimport#!/usr/bin/python

import os

import pyinotify

import fcntl

from pyinotify import WatchManager, Notifier, ThreadedNotifier, EventsCodes, ProcessEvent

try:

os.mkdir(os.environ['HOME']+"/pandora")

except:

pass

wm = WatchManager()

#mask = EventsCodes.IN_DELETE | EventsCodes.IN_CREATE # watched events

mask = EventsCodes.ALL_EVENTS

class PTmp(ProcessEvent):

f={}

# def process_IN_CREATE(self, event):

# print "Create: %s" % os.path.join(event.path, event.name)

# def process_IN_DELETE(self, event):

# print "Remove: %s" % os.path.join(event.path, event.name)

def process_default(self, event):

# print "Processing Some event?"

if event.name.startswith("Flash"):

print event

filename=event.path+"/"+event.name

if event.event_name=="IN_CREATE":

self.f[filename]=file(filename, mode="r")

fcntl.lockf(self.f[filename], fcntl.LOCK_SH)

if event.event_name.startswith("IN_DELETE") and self.f.has_key(filename):

print "DELETING"

self.f[filename].seek(0)

buf=self.f[filename].read(102)

# if len(buf)>100: # 100 bytes

# file("100dump",mode="a").write(buf[:100].encode("hex")+"\n")

self.f[filename].seek(0)

file(os.environ['HOME']+"/pandora/"+event.name,mode="w").write(self.f[filename].read())

fcntl.lockf(self.f[filename], fcntl.LOCK_UN)

if os.access(filename, os.R_OK):

os.unlink(filename)

notifier = Notifier(wm, PTmp())

wdd = wm.add_watch('/tmp', mask, rec=True)

while True: # loop forever

try:

# process the queue of events as explained above

notifier.process_events()

if notifier.check_events():

# read notified events and enqeue them

notifier.read_events()

# you can do some tasks here...

except KeyboardInterrupt:

# destroy the inotify's instance on this interrupt (stop monitoring)

notifier.stop()

------------end on line above-------

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...