All pastes #2132910 Raw Edit

Unnamed

public text v1 · immutable
#2132910 ·published 2012-03-27 18:38 UTC
rendered paste body
import time, sys, re

class ParserTest:
	def tomegabytes(string):
		spl = string.split(" ")
		if spl[1] == 'MB':
			return float(spl[0])
		if spl[1] == 'GB':
			return float(spl[0])*1000


	downs = {
		'tvsdx264': 'Scott_And_Bailey',
		'moviesdvdr': 'Die.Slow'
		}

	testInp =  "NEW in TV/SD-X264: -> Embarrassing.Bodies.S06E04.WS.PDTV.x264-C4TV (Uploaded 28 seconds after pre) - (299.39 MB) - (http://www.sceneaccess.org/details.php?id=537074)"


	m = re.findall('(?<=NEW in ).+(?=\: )', testInp)
	a = re.findall('(?<= -> ).+(?= \(Uploaded)', testInp)
	s = re.findall('\d+.\d+ [G|M]B', testInp)		
	u = re.findall('(?<=http://www\.sceneaccess\.org/details\.php\?id\=)\d+(?=\))', testInp)
	
	if m and a and s and u:
		cat = m[0].replace("/","").replace("-","").lower()
		rel = a[0]
		size = tomegabytes(s[0])
		tId = u[0]
		print "Maths: %s, %s, %s %s" %(cat, rel, size, tId)
	else:
		print "No match"


if __name__ == '__main__':
	p = ParserTest()