All pastes #2100635 Raw Edit

Stuff

public text v1 · immutable
#2100635 ·published 2012-01-07 05:34 UTC
rendered paste body
import urllib2, sys, os

def main(argv):
    URL = 'http://scenehd.org/reqlist.php'
    req = urllib2.Request(URL)

    def listdirs(folder):
        return [d for d in os.listdir(folder) if os.path.isdir(os.path.join(folder, d))]

    try:
        print 'Reading requestlist\n'
        response = urllib2.urlopen(req)
    except IOError, e:
        print e
    else:
        r = response.readlines()
        response.close()
        del r[0]
        try:
            if len(sys.argv) > 2:
                rls = listdirs(sys.argv[1])
                rls2 = listdirs(sys.argv[2])
                rls.extend(rls2)
            else:
                    rls = listdirs(sys.argv[1])
        except IOError:
            pass
        else:
            x = [s.replace('<br>\n', '').lstrip().rstrip() for s in r]
            z = [c.replace('\n', '').lstrip().rstrip() for c in rls]

            aa = set(x)
            bb = aa.intersection(z)
            
            for line in bb:
                print "REQ'ED: " + line


if __name__ == "__main__":
   main(sys.argv[0])