summaryrefslogtreecommitdiffstats
path: root/Imdb.py
diff options
context:
space:
mode:
Diffstat (limited to 'Imdb.py')
-rw-r--r--Imdb.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/Imdb.py b/Imdb.py
new file mode 100644
index 0000000..25df175
--- /dev/null
+++ b/Imdb.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+
+from urllib2 import urlopen
+from json import loads
+from urllib import quote_plus
+from re import findall
+
+def titleCode(title):
+ try:
+ html = urlopen("http://www.imdb.com/find?s=tt&q=" + quote_plus(title)).read()
+ except:
+ return ""
+ titleCodes = findall("/title/tt([0-9]{7})/", html)
+ if len(titleCodes) > 0:
+ return titleCodes[0]
+ else:
+ return "" \ No newline at end of file