The branch, dharma has been updated
via 212e666dc5891e7ac15c90dfa6385f78b45f315a (commit)
from 6ea066dfc2ec70fabad357aecc65ea1dd9e3aaaf (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=212e666dc5891e7ac15c90dfa6385f78b45f315a
commit 212e666dc5891e7ac15c90dfa6385f78b45f315a
Author: amet <[email protected]>
Date: Fri Apr 22 21:12:43 2011 +0400
[script.image.bigpictures] -v1.4.1
Fixed: boston.com now needs a referer for the photosets
Improved: Better class Inheritance
Cosmetic: pep8 (except line length)
Improved: The german, english and french usage instructions (and shorten
them)
Fixed: The Help now appears only on the first album or photoset
diff --git a/script.image.bigpictures/addon.xml
b/script.image.bigpictures/addon.xml
index 628b4be..33c890b 100644
--- a/script.image.bigpictures/addon.xml
+++ b/script.image.bigpictures/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="script.image.bigpictures" name="The Big Picture" version="1.4.0"
provider-name="sphere">
+<addon id="script.image.bigpictures" name="The Big Picture" version="1.4.1"
provider-name="sphere">
<requires>
<import addon="xbmc.python" version="1.0"/>
<import addon="script.module.beautifulsoup" version="3.0.8"/>
diff --git a/script.image.bigpictures/changelog.txt
b/script.image.bigpictures/changelog.txt
index ade33e9..9c5216d 100644
--- a/script.image.bigpictures/changelog.txt
+++ b/script.image.bigpictures/changelog.txt
@@ -1,3 +1,10 @@
+1.4.1
+ Fixed: boston.com now needs a referer for the photosets
+ Improved: Better class Inheritance
+ Cosmetic: pep8 (except line length)
+ Improved: The german, english and french usage instructions (and shorten
them)
+ Fixed: The Help now appears only on the first album or photoset
+
1.4.0
Changed: Skin has a new Look - thanks to Jezz_X
Changed: Skin is now animated
@@ -6,7 +13,7 @@
Changed: Split Sourcename, Albumtitle and Picturetitle for different use in
3rd party Skins
Improved: The toggle "showInfo" stays now in its last state
Improved: Respect pep8 styleguide (except line length...)
- Improved: Skin XML-File is now clean
+ Improved: Skin XML-File is now clean
1.3.2
Changed: Don't use 'os.getcwd()'
diff --git a/script.image.bigpictures/resources/language/English/strings.xml
b/script.image.bigpictures/resources/language/English/strings.xml
index 2fbbe8e..3885523 100644
--- a/script.image.bigpictures/resources/language/English/strings.xml
+++ b/script.image.bigpictures/resources/language/English/strings.xml
@@ -11,11 +11,11 @@
<string id="32024">to</string>
<string id="32025">of</string>
<!--Picture Mode -->
- <string id="32030">Left + Right - Switch Picture</string>
- <string id="32031">Info - Toggle Onscreen Information</string>
- <string id="32032">Context Menu - Download Photos</string>
+ <string id="32030">Left + Right = Switch Picture</string>
+ <string id="32031">Info = Toggle Onscreen Info</string>
+ <string id="32032">Context = Download Photos</string>
<!--Album Mode -->
- <string id="32040">Left + Right - Switch Album</string>
- <string id="32041">Up + Down - Switch Source</string>
- <string id="32042">Select - Enter Album</string>
+ <string id="32040">Left + Right = Switch Album</string>
+ <string id="32041">Up + Down = Switch Source</string>
+ <string id="32042">Select = Enter Album</string>
</strings>
\ No newline at end of file
diff --git a/script.image.bigpictures/resources/language/French/strings.xml
b/script.image.bigpictures/resources/language/French/strings.xml
index 19d10f1..9be52f1 100644
--- a/script.image.bigpictures/resources/language/French/strings.xml
+++ b/script.image.bigpictures/resources/language/French/strings.xml
@@ -11,11 +11,11 @@
<string id="32024">vers</string>
<string id="32025">/</string>
<!--Picture Mode -->
- <string id="32030">Gauche, Droite - Changer la photo</string>
- <string id="32031">Info - Affichage des informations à l'écran</string>
- <string id="32032">Menu contextuel - Téléchargement des photos</string>
+ <string id="32030">Gauche, Droite = Changer la photo</string>
+ <string id="32031">Info = Affichage des informations à l'écran</string>
+ <string id="32032">Contextuel = Téléchargement</string>
<!--Album Mode -->
- <string id="32040">Gauche, Droite - Changer l'album</string>
- <string id="32041">Haut, Bas - Changer la source</string>
- <string id="32042">Entrée - Ouvre l'album</string>
+ <string id="32040">Gauche, Droite = Changer l'album</string>
+ <string id="32041">Haut, Bas = Changer la source</string>
+ <string id="32042">Entrée = Ouvre l'album</string>
</strings>
diff --git a/script.image.bigpictures/resources/language/German/strings.xml
b/script.image.bigpictures/resources/language/German/strings.xml
index 1e400cd..1903b31 100644
--- a/script.image.bigpictures/resources/language/German/strings.xml
+++ b/script.image.bigpictures/resources/language/German/strings.xml
@@ -11,11 +11,11 @@
<string id="32024">nach</string>
<string id="32025">von</string>
<!--Picture Mode -->
- <string id="32030">Links + Rechts - Bild wechseln</string>
- <string id="32031">Info - OSD an/aus</string>
- <string id="32032">Kontext Menu - Bilder herunterladen</string>
+ <string id="32030">Links + Rechts = Bild wechseln</string>
+ <string id="32031">Info = OSD an/aus</string>
+ <string id="32032">Kontext = Bilder herunterladen</string>
<!--Album Mode -->
- <string id="32040">Links + Rechts - Album wechseln</string>
- <string id="32041">Hoch + Runter - Quelle wechseln</string>
- <string id="32042">Select - Album öffnen</string>
+ <string id="32040">Links + Rechts = Album wechseln</string>
+ <string id="32041">Hoch + Runter = Quelle wechseln</string>
+ <string id="32042">Select = Album öffnen</string>
</strings>
diff --git a/script.image.bigpictures/resources/lib/gui.py
b/script.image.bigpictures/resources/lib/gui.py
index d3510a4..a9c7dd4 100644
--- a/script.image.bigpictures/resources/lib/gui.py
+++ b/script.image.bigpictures/resources/lib/gui.py
@@ -53,6 +53,9 @@ class GUI(xbmcgui.WindowXML):
def onAction(self, action):
if action in self.ACTION_ANYKEY:
self.toggleHelp('false')
+ else:
+ pass
+ # print action.getId()
if action in self.ACTION_SHOW_INFO:
self.toggleInfo()
elif action in self.ACTION_CONTEXT_MENU:
@@ -81,6 +84,7 @@ class GUI(xbmcgui.WindowXML):
def onClick(self, controlId):
if controlId == self.CONTROL_MAIN_IMAGE:
+ self.toggleHelp('true')
if self.getProperty('type') == 'album':
self.showPhotos()
elif self.getProperty('type') == 'photo':
@@ -138,7 +142,6 @@ class GUI(xbmcgui.WindowXML):
imageDownloader.Download(photos, downloadPath)
def showPhotos(self): # the order is significant!
- self.toggleHelp('true')
self.getControl(self.CONTROL_USAGE_TEXT).setText('\n'.join([getLS(32030),
getLS(32031), getLS(32032)]))
link = self.getProperty('link')
self.getControl(self.CONTROL_MAIN_IMAGE).reset() # Clear the old list
of albums.
@@ -156,7 +159,6 @@ class GUI(xbmcgui.WindowXML):
self.showItems(photos, 'photo')
def showAlbums(self):
- self.toggleHelp('true')
self.getControl(self.CONTROL_USAGE_TEXT).setText('\n'.join([getLS(32040),
getLS(32041), getLS(32042)]))
self.getControl(self.CONTROL_MAIN_IMAGE).reset() # This is necessary
when returning from photos.
if self.SOURCES[self.ACTIVESOURCE]['object'] == 'tbp':
diff --git a/script.image.bigpictures/resources/lib/sbb_scraper.py
b/script.image.bigpictures/resources/lib/sbb_scraper.py
index 8309e0c..92aeab4 100644
--- a/script.image.bigpictures/resources/lib/sbb_scraper.py
+++ b/script.image.bigpictures/resources/lib/sbb_scraper.py
@@ -1,51 +1,12 @@
-import urllib2
-import re
-import sys
+from scraper import Scraper
from BeautifulSoup import BeautifulSoup
-scriptName = sys.modules['__main__'].__scriptname__
-
-class SBB:
-
- def getHTML(self, url, headers=[('User-Agent', 'Mozilla/5.0 (Windows; U;
Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')]):
- """Returns HTML from a given URL"""
- opener = urllib2.build_opener()
- opener.addheaders = headers
- try:
- # print '[SCRIPT][%s] %s attempting to open %s' % (scriptName,
__name__, url)
- usock = opener.open(url)
- response = usock.read()
- usock.close()
- return response
- except urllib2.HTTPError, error:
- print '[SCRIPT][%s] %s error opening %s' % (scriptName, __name__,
url)
- print error.msg, error.code, error.geturl()
- try:
- import xbmcgui
- xbmcgui.Dialog().ok(error.msg, '%s\n%s' % (error.code,
error.geturl()))
- except:
- pass
-
- def cleanHTML(self, s):
- """The 2nd half of this removes HTML tags.
- The 1st half deals with the fact that beautifulsoup sometimes spits
- out a list of NavigableString objects instead of a regular string.
- This only happens when there are HTML elements, so it made sense to
- fix both problems in the same function."""
- tmp = list()
- for ns in s:
- tmp.append(str(ns))
- s = ''.join(tmp)
- s = re.sub('\s+', ' ', s) # remove extra spaces
- s = re.sub('<.+?>|Image:.+?\r|\r', '', s) # remove htmltags, image
captions, & newlines
- s = s.replace(''', '\'') # replace html-encoded double-quotes
- s = s.strip()
- return s
+class SBB(Scraper):
def getAlbums(self, url):
"""creates an ordered list albums = [{title, pic, description, link},
...]"""
- tree = BeautifulSoup(self.getHTML(url))
+ tree = BeautifulSoup(self.getCachedURL(url))
self.albums = list()
storyNodes = tree.findAll('div', 'entry-asset asset hentry story')
for node in storyNodes:
@@ -57,7 +18,7 @@ class SBB:
def getPhotos(self, url):
"""creates an ordered list photos = [{title, pic, description}, ...]
"""
- tree = BeautifulSoup(self.getHTML(url))
+ tree = BeautifulSoup(self.getCachedUrl(url))
title = tree.find('div', 'asset-name entry-title title').a.string
self.photos = list()
subtree_img = tree.findAll('div', attrs={'style': 'background:
rgb(224, 224, 224); width: 982px; padding: 4px;'})
diff --git a/script.image.bigpictures/resources/lib/tbp_scraper.py
b/script.image.bigpictures/resources/lib/tbp_scraper.py
index 452af96..940b262 100644
--- a/script.image.bigpictures/resources/lib/tbp_scraper.py
+++ b/script.image.bigpictures/resources/lib/tbp_scraper.py
@@ -1,53 +1,14 @@
-import urllib2
+from scraper import Scraper
import re
-import sys
from BeautifulSoup import BeautifulSoup
-scriptName = sys.modules['__main__'].__scriptname__
-
-class TBP:
-
- def getHTML(self, url, headers=[('User-Agent', 'Mozilla/5.0 (Windows; U;
Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')]):
- """Returns HTML from a given URL"""
- opener = urllib2.build_opener()
- opener.addheaders = headers
- try:
- # print '[SCRIPT][%s] %s attempting to open %s' % (scriptName,
__name__, url)
- usock = opener.open(url)
- response = usock.read()
- usock.close()
- return response
- except urllib2.HTTPError, error:
- print '[SCRIPT][%s] %s error opening %s' % (scriptName, __name__,
url)
- print error.msg, error.code, error.geturl()
- try:
- import xbmcgui
- xbmcgui.Dialog().ok(error.msg, '%s\n%s' % (error.code,
error.geturl()))
- except:
- pass
-
- def cleanHTML(self, s):
- """The 2nd half of this removes HTML tags.
- The 1st half deals with the fact that beautifulsoup sometimes spits
- out a list of NavigableString objects instead of a regular string.
- This only happens when there are HTML elements, so it made sense to
- fix both problems in the same function."""
- tmp = list()
- for ns in s:
- tmp.append(str(ns))
- s = ''.join(tmp)
- s = re.sub('\s+', ' ', s) # remove extra spaces
- s = re.sub('<.+?>|Image:.+?\r|\r', '', s) # remove htmltags, image
captions, & newlines
- s = s.replace(''', '\'') # replace html-encoded double-quotes
- s = re.sub('#$', '', s) # remove hash at the end
- s = s.strip()
- return s
+class TBP(Scraper):
def getFilters(self, url):
"""TBP lets you filter results by categories or months.
creatues a list of those filters: [[month|category,url], ...]"""
- tree = BeautifulSoup(self.getHTML(url))
+ tree = BeautifulSoup(self.getCachedURL(url))
self.months = list()
self.categories = list()
optionNodes = tree.findAll('option', value=re.compile('.+?'))
@@ -59,7 +20,7 @@ class TBP:
def getAlbums(self, url):
"""creates an ordered list albums = [{title, pic, description, link},
...]"""
- tree = BeautifulSoup(self.getHTML(url))
+ tree = BeautifulSoup(self.getCachedURL(url))
self.albums = list()
storyNodes = tree.findAll('div', 'headDiv2')
for node in storyNodes:
@@ -71,7 +32,8 @@ class TBP:
def getPhotos(self, url):
"""creates an ordered list photos = [{title, pic, description}, ...]
"""
- tree = BeautifulSoup(self.getHTML(url))
+ referer = 'http://www.boston.com/bigpicture/'
+ tree = BeautifulSoup(self.getCachedURL(url, referer))
title = tree.find('div', 'headDiv2').h2.a.string
self.photos = list()
photoNodes = tree.findAll('div', {'class':
re.compile('bpImageTop|bpBoth')})
diff --git a/script.image.bigpictures/resources/lib/wsj_scraper.py
b/script.image.bigpictures/resources/lib/wsj_scraper.py
index 7bbb67a..ad7fe15 100644
--- a/script.image.bigpictures/resources/lib/wsj_scraper.py
+++ b/script.image.bigpictures/resources/lib/wsj_scraper.py
@@ -1,53 +1,12 @@
-import urllib2
-import re
-import sys
+from scraper import Scraper
from BeautifulSoup import BeautifulSoup
-scriptName = sys.modules['__main__'].__scriptname__
-
-class WSJ:
-
- def getHTML(self, url, headers=[('User-Agent', 'Mozilla/5.0 (Windows; U;
Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14')]):
- """Returns HTML from a given URL"""
- opener = urllib2.build_opener()
- opener.addheaders = headers
- try:
- # print '[SCRIPT][%s] %s attempting to open %s' % (scriptName,
__name__, url)
- usock = opener.open(url)
- response = usock.read()
- usock.close()
- return response
- except urllib2.HTTPError, error:
- print '[SCRIPT][%s] %s error opening %s' % (scriptName, __name__,
url)
- print error.msg, error.code, error.geturl()
- try:
- import xbmcgui
- xbmcgui.Dialog().ok(error.msg, '%s\n%s' % (error.code,
error.geturl()))
- except:
- pass
-
- def cleanHTML(self, s):
- """The 2nd half of this removes HTML tags.
- The 1st half deals with the fact that beautifulsoup sometimes spits
- out a list of NavigableString objects instead of a regular string.
- This only happens when there are HTML elements, so it made sense to
- fix both problems in the same function."""
- tmp = list()
- for ns in s:
- tmp.append(str(ns))
- s = ''.join(tmp)
- s = re.sub('\s+', ' ', s) # remove extra spaces
- s = re.sub('<.+?>|Image:.+?\r|\r', '', s) # remove htmltags, image
captions, & newlines
- s = s.replace(''', '\'') # replace html-encoded double-quotes
- s = s.replace('’', '\'') # replace html-encoded single-quotes
- s = s.replace('”', '"') # replace html-encoded double-quotes
- s = s.strip()
- return s
+class WSJ(Scraper):
def getAlbums(self, url):
"""creates an ordered list albums = [{title, pic, description, link},
...]"""
- tree = BeautifulSoup(self.getHTML(url))
+ tree = BeautifulSoup(self.getCachedURL(url))
self.albums = list()
storyNodes = tree.findAll('li', 'postitem imageFormat-P')
for node in storyNodes:
@@ -59,7 +18,7 @@ class WSJ:
def getPhotos(self, url, append=False):
"""creates an ordered list photos = [{title, pic, description}, ...]
"""
- tree = BeautifulSoup(self.getHTML(url))
+ tree = BeautifulSoup(self.getCachedUrl(url))
title = tree.find('div', 'articleHeadlineBox
headlineType-newswire').h1.string
if not append:
self.photos = list()
diff --git a/script.image.bigpictures/runscript.py
b/script.image.bigpictures/runscript.py
index 018104f..3218efc 100644
--- a/script.image.bigpictures/runscript.py
+++ b/script.image.bigpictures/runscript.py
@@ -9,6 +9,7 @@ __id__ = Addon.getAddonInfo('id')
__author__ = Addon.getAddonInfo('author')
__version__ = Addon.getAddonInfo('version')
__path__ = Addon.getAddonInfo('path')
+__cachedir__ = 'special://profile/addon_data/%s/cache/' % __id__
print '[SCRIPT][%s] version %s initialized!' % (__scriptname__, __version__)
@@ -21,4 +22,3 @@ if (__name__ == '__main__'):
print '[SCRIPT][%s] version %s exited!' % (__scriptname__, __version__)
del ui
sys.modules.clear()
-
-----------------------------------------------------------------------
Summary of changes:
script.image.bigpictures/addon.xml | 2 +-
script.image.bigpictures/changelog.txt | 9 +++-
.../resources/language/English/strings.xml | 12 ++--
.../resources/language/French/strings.xml | 12 ++--
.../resources/language/German/strings.xml | 12 ++--
script.image.bigpictures/resources/lib/gui.py | 6 +-
.../resources/lib/sbb_scraper.py | 47 +-------------
script.image.bigpictures/resources/lib/scraper.py | 65 ++++++++++++++++++++
.../resources/lib/tbp_scraper.py | 50 ++-------------
.../resources/lib/wsj_scraper.py | 49 +--------------
script.image.bigpictures/runscript.py | 2 +-
11 files changed, 111 insertions(+), 155 deletions(-)
create mode 100644 script.image.bigpictures/resources/lib/scraper.py
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
Fulfilling the Lean Software Promise
Lean software platforms are now widely adopted and the benefits have been
demonstrated beyond question. Learn why your peers are replacing JEE
containers with lightweight application servers - and what you can gain
from the move. http://p.sf.net/sfu/vmware-sfemails
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons