vi:si:et:sw=4:sts=4:ts=4

This commit is contained in:
j 2008-06-19 11:47:02 +02:00
parent 8886cfe8d3
commit 4c14ce613d
16 changed files with 1088 additions and 1134 deletions

View file

@ -1,7 +1,5 @@
# -*- Mode: Python; -*- # vi:si:et:sw=4:sts=4:ts=4
# vi:si:et:sw=2:sts=2:ts=2
# encoding: utf-8 # encoding: utf-8
__version__ = '0.1.0' __version__ = '0.1.0'
import imdb import imdb

View file

@ -7,6 +7,7 @@ from oxutils.cache import getUrlUnicode
from oxutils.html import stripTags from oxutils.html import stripTags
from oxutils.text import findRe, removeSpecialCharacters from oxutils.text import findRe, removeSpecialCharacters
def getData(criterionId): def getData(criterionId):
''' '''
>>> getData(348)['imdbId'] >>> getData(348)['imdbId']

View file

@ -1,7 +1,10 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
import re import re
from urllib import unquote from urllib import unquote
from oxutils.cache import getUrl from oxutils.cache import getUrl
def getVideoUrl(url): def getVideoUrl(url):
''' '''
>>> getVideoUrl('http://www.dailymotion.com/relevance/search/priere%2Bpour%2Brefuznik/video/x3opar_priere-pour-refuznik-1-jeanluc-goda_shortfilms') >>> getVideoUrl('http://www.dailymotion.com/relevance/search/priere%2Bpour%2Brefuznik/video/x3opar_priere-pour-refuznik-1-jeanluc-goda_shortfilms')

View file

@ -1,6 +1,5 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2 # vi:si:et:sw=4:sts=4:ts=4
import re import re
import time import time
import urllib import urllib
@ -49,4 +48,3 @@ def find(query, max_results=DEFAULT_MAX_RESULTS):
results = results[:max_results] results = results[:max_results]
return results return results

View file

@ -1,11 +1,8 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2 # vi:si:et:sw=4:sts=4:ts=4
from oxutils import *
import urllib2 import urllib2
from urllib import quote, unquote from urllib import quote, unquote
import re, time import re
import os import os
import time import time
@ -15,20 +12,10 @@ import oxutils
from oxutils import stripTags, decodeHtml, findRe, findString from oxutils import stripTags, decodeHtml, findRe, findString
from oxutils.cache import getUrl, getUrlUnicode from oxutils.cache import getUrl, getUrlUnicode
from oxutils.normalize import normalizeTitle, normalizeImdbId from oxutils.normalize import normalizeTitle, normalizeImdbId
from oxutils import *
import google import google
_timer = -1
_timer_last = -1
def debugTime(message=''):
global _timer, _timer_last
if _timer == -1:
_timer = time.time()
if _timer_last == -1:
_timer_last = time.time()
now = time.time()
print message," since last: %0.2f total time: %0.2f" % (now-_timer_last, now-_timer)
_timer_last = now
def getMovieId(title, director='', year=''): def getMovieId(title, director='', year=''):
''' '''
@ -346,20 +333,6 @@ def getMovieReleaseDates(imdbId):
decodeHtml(stripTags(r[2]).strip())) decodeHtml(stripTags(r[2]).strip()))
releasedates.append(r_) releasedates.append(r_)
return releasedates return releasedates
soup = BeautifulSoup(data)
info = soup('table',{'border': '0', 'cellpadding':'2'})
if info:
for row in info[0]('tr'):
d = row('td', {'align':'right'})
if d:
try:
possible_date = stripTags(unicode(d[0])).strip()
rdate = time.strptime(possible_date, "%d %B %Y")
rdate = time.strftime('%Y-%m-%d', rdate)
return rdate
except:
pass
return None
def getMovieBusinessSum(imdbId): def getMovieBusinessSum(imdbId):
business = getMovieBusiness(imdbId) business = getMovieBusiness(imdbId)
@ -389,24 +362,6 @@ def getMovieBusiness(imdbId):
value = [decodeHtml(stripTags(b).strip()) for b in r[1].split('<br/>')] value = [decodeHtml(stripTags(b).strip()) for b in r[1].split('<br/>')]
business[key] = value business[key] = value
return business return business
soup = BeautifulSoup(data)
business = {'budget': 0, 'gross': 0, 'profit': 0}
content = soup('div', {'id': 'tn15content'})[0]
blocks = unicode(content).split('<h5>')[1:]
for c in blocks:
cs = BeautifulSoup(c)
line = c.split('</h5>')
if line:
title = line[0]
line = line[1]
if title in ['Budget', 'Gross']:
values = re.compile('\$(.*?) ').findall(line)
values = [int(value.replace(',','')) for value in values]
if values:
business[title.lower()] = max(values)
if business['budget'] and business['gross']:
business['profit'] = business['gross'] - business['budget']
return business
def getMovieEpisodes(imdbId): def getMovieEpisodes(imdbId):
url = "%s/episodes" % getUrlBase(imdbId) url = "%s/episodes" % getUrlBase(imdbId)
@ -700,3 +655,4 @@ if __name__ == '__main__':
import sys import sys
#print parse(sys.argv[1]) #print parse(sys.argv[1])
print "imdb:", guess(sys.argv[1]) print "imdb:", guess(sys.argv[1])

View file

@ -1,3 +1,5 @@
# vi:si:et:sw=4:sts=4:ts=4
# encoding: utf-8
import re import re
import ox.imdb as imdb import ox.imdb as imdb

View file

@ -1,3 +1,5 @@
# vi:si:et:sw=4:sts=4:ts=4
# encoding: utf-8
import re import re
import urllib import urllib
@ -6,6 +8,7 @@ from oxutils.html import decodeHtml, stripTags
from oxutils.text import findRe from oxutils.text import findRe
from oxutils.text import findString from oxutils.text import findString
# to sniff itunes traffic, use something like # to sniff itunes traffic, use something like
# sudo tcpdump -i en1 -Avs 8192 host appleglobal.112.2o7.net # sudo tcpdump -i en1 -Avs 8192 host appleglobal.112.2o7.net
@ -181,3 +184,4 @@ if __name__ == '__main__':
print simplejson.dumps(data, sort_keys = True, indent = 4) print simplejson.dumps(data, sort_keys = True, indent = 4)
data = ItunesMovie(id='272960052').getData() data = ItunesMovie(id='272960052').getData()
print simplejson.dumps(data, sort_keys = True, indent = 4) print simplejson.dumps(data, sort_keys = True, indent = 4)

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from oxutils.cache import getUrl from oxutils.cache import getUrl
from oxutils.html import decodeHtml from oxutils.html import decodeHtml
from oxutils.text import findRe from oxutils.text import findRe

View file

@ -1,7 +1,5 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2 # vi:si:et:sw=4:sts=4:ts=4
from datetime import datetime from datetime import datetime
import re import re
import socket import socket
@ -14,7 +12,6 @@ import oxutils
from torrent import Torrent from torrent import Torrent
socket.setdefaulttimeout(10.0)
def _parseResultsPage(data, max_results=10): def _parseResultsPage(data, max_results=10):
results=[] results=[]

View file

@ -1,6 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2 # vi:si:et:sw=4:sts=4:ts=4
import re import re
import feedparser import feedparser
@ -21,10 +20,8 @@ def findSubtitlesByImdb(imdb, parts = 1, language = "eng"):
if "title>opensubtitles.com - search results</title" in data: if "title>opensubtitles.com - search results</title" in data:
fd = feedparser.parse(data) fd = feedparser.parse(data)
opensubtitleId = None opensubtitleId = None
print url
if fd.entries: if fd.entries:
link = fd.entries[0]['links'][0]['href'] link = fd.entries[0]['links'][0]['href']
print link
opensubtitleId = re.compile('subtitles/(.*?)/').findall(link) opensubtitleId = re.compile('subtitles/(.*?)/').findall(link)
if opensubtitleId: if opensubtitleId:
opensubtitleId = opensubtitleId[0] opensubtitleId = opensubtitleId[0]
@ -42,4 +39,3 @@ def downloadSubtitleById(opensubtitle_id):
srts[name] = getUrlUnicode(url) srts[name] = getUrlUnicode(url)
return srts return srts

View file

@ -1,3 +1,5 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from datetime import datetime from datetime import datetime
import re import re
import time import time
@ -8,6 +10,7 @@ import oxutils.cache
from oxutils.html import decodeHtml, stripTags from oxutils.html import decodeHtml, stripTags
import oxutils.net import oxutils.net
def getNews(year, month, day): def getNews(year, month, day):
sections = [ sections = [
'politik', 'wirtschaft', 'panorama', 'sport', 'kultur', 'netzwelt', 'politik', 'wirtschaft', 'panorama', 'sport', 'kultur', 'netzwelt',

View file

@ -1,14 +1,11 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2 # vi:si:et:sw=4:sts=4:ts=4
from datetime import datetime from datetime import datetime
import re import re
import socket import socket
from urllib import quote, urlencode from urllib import quote, urlencode
from urllib2 import URLError from urllib2 import URLError
from oxutils.cache import getUrl, getUrlUnicode from oxutils.cache import getUrl, getUrlUnicode
from oxutils import findRe, cache, stripTags, decodeHtml, getTorrentInfo, normalizeNewlines from oxutils import findRe, cache, stripTags, decodeHtml, getTorrentInfo, normalizeNewlines
from oxutils.normalize import normalizeImdbId from oxutils.normalize import normalizeImdbId
@ -16,7 +13,6 @@ import oxutils
from torrent import Torrent from torrent import Torrent
socket.setdefaulttimeout(10.0)
season_episode = re.compile("S..E..", re.IGNORECASE) season_episode = re.compile("S..E..", re.IGNORECASE)

View file

@ -1,7 +1,5 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2 # vi:si:et:sw=4:sts=4:ts=4
from oxutils import intValue from oxutils import intValue

View file

@ -1,12 +1,12 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2 # vi:si:et:sw=4:sts=4:ts=4
from urllib import urlencode from urllib import urlencode
import simplejson import simplejson
from oxutils.cache import getUrl, getUrlUnicode from oxutils.cache import getUrl, getUrlUnicode
from oxutils import findRe, decodeHtml from oxutils import findRe, decodeHtml
def getMovieId(title, director='', year=''): def getMovieId(title, director='', year=''):
query = '"%s" film %s %s' % (title, director, year) query = '"%s" film %s %s' % (title, director, year)
result = find(query, 1) result = find(query, 1)

View file

@ -1,6 +1,5 @@
# -*- Mode: Python; -*-
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# vi:si:et:sw=2:sts=2:ts=2 # vi:si:et:sw=4:sts=4:ts=4
from urllib import quote from urllib import quote
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
@ -8,6 +7,7 @@ import feedparser
from oxutils.cache import getUrl from oxutils.cache import getUrl
from oxutils import findString from oxutils import findString
def getVideoUrl(youtubeId, format='mp4'): def getVideoUrl(youtubeId, format='mp4'):
url = 'http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=' + youtubeId url = 'http://www.youtube.com/api2_rest?method=youtube.videos.get_video_token&video_id=' + youtubeId
data = getUrl(url) data = getUrl(url)

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
# vi:si:et:sw=2:sts=2:ts=2 # vi:si:et:sw=4:sts=4:ts=4
# encoding: utf-8 # encoding: utf-8
from setuptools import setup, find_packages from setuptools import setup, find_packages
@ -29,5 +29,5 @@ setup(
'Programming Language :: Python', 'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules', 'Topic :: Software Development :: Libraries :: Python Modules',
], ],
) )