~davidc3/onehundredscopes/youporn-precise

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#! /usr/bin/python
# -*- coding: latin-1 -*-

from gi.repository import GLib
import gio
from lxml.html import fromstring
import urllib2
import sys

vlc = gio.File('/usr/bin/vlc')
if vlc.query_exists():
	GLib.spawn_command_line_async("vlc --one-instance")
else:
	GLib.spawn_command_line_async("totem --replace")

print "########"
print "tiny-video-parser : start"
video= ''

uri = sys.argv[1]
print "URI=%s" % uri
results = urllib2.urlopen(uri).read()
tree = fromstring(results)
for a in tree.cssselect('div ul li p a'):
	if a.get('href').startswith("http://download.youporn.com/download/") and 'MP4' in a.text_content():
		video = a.get('href')
		source = a.text_content()
	elif a.get('href').startswith("http://download.youporn.com/download/") and 'MPG' in a.text_content():
		video = a.get('href')
		source = a.text_content()
	else:
		pass

print "TYPE=%s" % source
print "STREAM=%s" % video
if vlc.query_exists():
	GLib.spawn_command_line_async("vlc --one-instance '%s'" % video)
else:
	GLib.spawn_command_line_async("totem --replace '%s'" % video)