-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmklist-publicdomaintorrents
executable file
·58 lines (51 loc) · 1.72 KB
/
mklist-publicdomaintorrents
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
"""
Extract IMDB IDs of movies listed as in the public domain on
www.publicdomaintorrents.info.
"""
import json
import lxml.html
import movielib
import urllib2
import urlparse
def get_movie_info(entryurl):
try:
root = lxml.html.fromstring(movielib.http_get_read(entryurl))
except urllib2.HTTPError as e:
return None
for a in root.cssselect("td a"):
#print a.attrib['href'], a.attrib['href'].find("imdb")
if -1 != a.attrib['href'].find("imdb.com"):
imdburl = a.attrib['href']
imdburl = imdburl.replace('/imdb.com/', '/www.imdb.com/')
if '/' != imdburl[-1]:
imdburl = imdburl + '/'
#print imdburl
return imdburl
print("Unable to find IMDB id for %s" % entryurl)
def get_movie_list(summaryurl):
try:
root = lxml.html.fromstring(movielib.http_get_read(summaryurl))
except urllib2.HTTPError as e:
return "n/a"
l = {}
for a in root.cssselect("table tr td a"):
#print a, a.attrib['href'].find("nshowmovie.html?movieid=")
if -1 != a.attrib['href'].find("nshowmovie.html?movieid="):
title = a.text_content()
entryurl = urlparse.urljoin(summaryurl, a.attrib['href'])
e = get_movie_info(entryurl)
if not e:
e = entryurl
l[e] = {
'status' : 'free',
'freenessurl' : entryurl,
'title' : title,
}
return l
def main():
summaryurl = 'http://www.publicdomaintorrents.info/nshowcat.html?category=ALL'
l = get_movie_list(summaryurl)
movielib.savelist(l, 'free-movies-publicdomaintorrents.json')
if __name__ == '__main__':
main()