source: ipk/source/swapbrowsers_picasa/var/swap/extensions/Picasa/plugin.py@ 7283

Last change on this file since 7283 was 7283, checked in by madie, 15 years ago

[ipk] add picasa for swap

File size: 77.1 KB
Line 
1# -*- coding: utf-8 -*-
2
3#-------------------------------------------------------
4#
5# AAF Picasa Viewer
6#
7# Dieses Plugin dient zur Betrachtung verschiedener
8# Bilder des Google Dienstes "Picasa".
9# Es besteht grunsaetzlich die Moeglichkeit dort kostenlose
10# Userkonten anzulegen und eigene Bilder hochladen. Diese
11# koennen dann ebenfalls mit diesem Plugn betrachtet werden.
12#
13# Wir wuenschen allen Benutzern viel Spaß mit diesem
14# nuetzlichem Plugin.
15#
16# http://picasaweb.google.com
17#
18# 12.09.2010
19#
20#
21# Designed und Idee von
22# @Bauernbub
23#
24#-------------------------------------------------------
25
26from enigma import *
27from enigma import eActionMap
28from Screens.Screen import Screen
29from Screens.ServiceInfo import ServiceInfoList, ServiceInfoListEntry
30from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
31from Components.Pixmap import Pixmap, MovingPixmap
32from Components.Label import Label
33from Components.Button import Button
34from Components.Sources.List import List
35from Screens.MessageBox import MessageBox
36from Screens.HelpMenu import HelpableScreen
37from Components.ConfigList import ConfigList
38from Components.config import *
39from Tools.Directories import resolveFilename, fileExists, pathExists, createDir, SCOPE_MEDIA
40from Components.FileList import FileList
41from Components.AVSwitch import AVSwitch
42from Plugins.Plugin import PluginDescriptor
43from Screens.VirtualKeyBoard import VirtualKeyBoard
44from Components.ConfigList import ConfigListScreen
45from os import path as os_path
46from os import system, remove, walk, makedirs, listdir, chdir
47from Screens.NetworkSetup import *
48from twisted.web.client import downloadPage
49from Components.HTMLComponent import HTMLComponent
50from Components.GUIComponent import GUIComponent
51
52from Screens.InfoBarGenerics import InfoBarResolutionSelection
53#from Plugins.Extensions.MediaCenter.GlobalFunctions import InfoBarAspectSelection
54
55
56from Screens.VirtualKeyBoard import VirtualKeyBoard
57from Components.Sources.Progress import Progress
58from re import sub, split, search, match, findall
59
60import os
61import sys
62import urllib
63
64
65#-------------- nur fuer manuelles compilieren auf der Box -----------------------------------------
66# import py_compile
67# py_compile.compile("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/plugin.py")
68
69global path
70global Fokus
71global devicepath
72global maxpage
73global curpage
74global loadpicnow
75global box
76
77maxpage = 1
78curpage = 1
79loadpicnow = 0
80
81Fokus = 2 # Defaultwert zeigt erste Maske
82page = "none"
83index = 0 # for picviewer
84
85# Boytyp lesen
86file = open("/proc/stb/info/model", "r")
87box = file.readline().strip()
88file.close()
89
90
91config.plugins.picasa = ConfigSubsection()
92config.plugins.picasa.max_offsety = ConfigInteger(default=15, limits=(0, 50))
93config.plugins.picasa.Device = ConfigSelection(default="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/", choices = [("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/", _("...Plugins/Extensions/Picasa/")), ("/media/hdd/Picasa/", _("/media/hdd/Picasa/")), ("/var/swap/Picasa/", _("/var/swap/Picasa/"))])
94config.plugins.picasa.resize = ConfigSelection(default="0", choices = [("0", _("simple")), ("1", _("better"))])
95config.plugins.picasa.bgcolor = ConfigSelection(default="#00000000", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
96config.plugins.picasa.textcolor = ConfigSelection(default="#0038FF48", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
97config.plugins.picasa.framesize = ConfigInteger(default=5, limits=(5, 99))
98config.plugins.picasa.max_otherpic = ConfigInteger(default=6, limits=(1, 25))
99config.plugins.picasa.max_picpixel = ConfigSelection(default="1024", choices = [("640", _("640")), ("800", _("800")), ("1024", _("1024")), ("1200", _("1200")), ("2048", _("2048"))])
100config.plugins.picasa.remove = ConfigSelection(default="0", choices = [("0", _("Yes")), ("1", _("No"))])
101config.plugins.picasa.slidetime = ConfigInteger(default=5, limits=(3, 60))
102config.plugins.picasa.infoline = ConfigEnableDisable(default=True)
103config.plugins.picasa.loop = ConfigEnableDisable(default=True)
104devicepath = config.plugins.picasa.Device.value
105
106
107#---------------------- Skin Funktionen -----------------------------------------------------------
108def getAspect():
109 val = AVSwitch().getAspectRatioSetting()
110 return val/2
111
112def getScale():
113 return AVSwitch().getFramebufferScale()
114
115def applySkinVars(skin,dict):
116 for key in dict.keys():
117 try:
118 skin = skin.replace('{'+key+'}',dict[key])
119 except Exception,e:
120 print e,"@key=",key
121 return skin
122
123
124#-------------------- ist der voreingestellte Device noch vorhanden? ------------------------
125if devicepath == "/media/hdd/Picasa/":
126 if not pathExists("/media/hdd/Picasa"):
127 devicepath = "/usr/lib/enigma2/python/Plugins/Extensions/Picasa/"
128 config.plugins.picasa.Device = devicepath
129 config.plugins.picasa.Device.save
130 session.open(MessageBox, _("not existing Device (hdd)!"), type = MessageBox.TYPE_INFO, timeout = 10)
131
132if devicepath == "/var/swap/Picasa/":
133 if not pathExists("/var/swap/Picasa"):
134 devicepath = "/usr/lib/enigma2/python/Plugins/Extensions/Picasa/"
135 config.plugins.picasa.Device = devicepath
136 config.plugins.picasa.Device.save
137 config.save()
138 session.open(MessageBox, _("not existing Device (swap)!"), type = MessageBox.TYPE_INFO, timeout = 10)
139
140os.system("chmod 755 /usr/lib/enigma2/python/Plugins/Extensions/Picasa/rss.sh")
141os.system("chmod 755 /usr/lib/enigma2/python/Plugins/Extensions/Picasa/private.sh")
142
143
144#------------------------------------------------------------------------------------------
145#---------------------- class InfoBarAspectSelection --------------------------------------
146#------------------------------------------------------------------------------------------
147
148class InfoBarAspectSelection:
149 STATE_HIDDEN = 0
150 STATE_ASPECT = 1
151 STATE_RESOLUTION = 2
152 def __init__(self):
153 self["AspectSelectionAction"] = HelpableActionMap(self, "InfobarAspectSelectionActions",
154 {
155 "aspectSelection": (self.ExGreen_toggleGreen, _("Aspect list...")),
156 })
157 self.__ExGreen_state = self.STATE_HIDDEN
158 def ExGreen_doAspect(self):
159 self.__ExGreen_state = self.STATE_ASPECT
160 self.aspectSelection()
161 def ExGreen_doResolution(self):
162 self.__ExGreen_state = self.STATE_RESOLUTION
163 self.resolutionSelection()
164 def ExGreen_doHide(self):
165 self.__ExGreen_state = self.STATE_HIDDEN
166 def ExGreen_toggleGreen(self, arg=""):
167 print self.__ExGreen_state
168 if self.__ExGreen_state == self.STATE_HIDDEN:
169 print "self.STATE_HIDDEN"
170 self.ExGreen_doAspect()
171 elif self.__ExGreen_state == self.STATE_ASPECT:
172 print "self.STATE_ASPECT"
173 self.ExGreen_doResolution()
174 elif self.__ExGreen_state == self.STATE_RESOLUTION:
175 print "self.STATE_RESOLUTION"
176 self.ExGreen_doHide()
177 def aspectSelection(self):
178 selection = 0
179 tlist = []
180 tlist.append((_("Resolution"), "resolution"))
181 tlist.append(("", ""))
182 tlist.append(("Letterbox", "letterbox"))
183 tlist.append(("PanScan", "panscan"))
184 tlist.append(("Non Linear", "non"))
185 tlist.append(("Bestfit", "bestfit"))
186 mode = open("/proc/stb/video/policy").read()[:-1]
187 print mode
188 for x in range(len(tlist)):
189 if tlist[x][1] == mode:
190 selection = x
191 keys = ["green", "", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ]
192 self.session.openWithCallback(self.aspectSelected, ChoiceBox, title=_("Please select an aspect ratio..."), list = tlist, selection = selection, keys = keys)
193 def aspectSelected(self, aspect):
194 if not aspect is None:
195 if isinstance(aspect[1], str):
196 if aspect[1] == "resolution":
197 self.ExGreen_toggleGreen()
198 else:
199 open("/proc/stb/video/policy", "w").write(aspect[1])
200 self.ExGreen_doHide()
201 return
202
203#------------------------------------------------------------------------------------------
204#----------------------------- Picasa Empfohlene Fotos ------------------------------------
205#------------------------------------------------------------------------------------------
206class PicasaMain(Screen):
207 devicepath = config.plugins.picasa.Device.value
208
209 skin = """
210 <screen name="Picasa" position="{picasa.pos}" size="{picasa.size}" title="Empfohlene Fotos - Picasa Version V 1.1" backgroundColor="#000000" >
211 <widget name="Pic1a" position="{pic1a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
212 <widget name="Pic2a" position="{pic2a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
213 <widget name="Pic3a" position="{pic3a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
214 <widget name="Pic4a" position="{pic4a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
215 <widget name="Pic5a" position="{pic5a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
216 <widget name="Pic6a" position="{pic6a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
217 <widget name="Pic7a" position="{pic7a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
218 <widget name="Pic8a" position="{pic8a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
219 <widget name="Pic9a" position="{pic9a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
220 <widget name="Pic10a" position="{pic10a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
221 <widget name="Pic11a" position="{pic11a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
222 <widget name="Pic12a" position="{pic12a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
223 <widget name="Pic1" position="{pic1.pos}" zPosition="3" size="144,144" pixmap="{dev}mainpic/pic_1.jpg" transparent="1" alphatest="on" />
224 <widget name="Pic2" position="{pic2.pos}" zPosition="3" size="144,144" pixmap="{dev}mainpic/pic_2.jpg" transparent="1" alphatest="on" />
225 <widget name="Pic3" position="{pic3.pos}" zPosition="3" size="144,144" pixmap="{dev}mainpic/pic_3.jpg" transparent="1" alphatest="on" />
226 <widget name="Pic4" position="{pic4.pos}" zPosition="3" size="144,144" pixmap="{dev}mainpic/pic_4.jpg" transparent="1" alphatest="on" />
227 <widget name="Pic5" position="{pic5.pos}" zPosition="4" size="144,144" pixmap="{dev}mainpic/pic_5.jpg" transparent="1" alphatest="on" />
228 <widget name="Pic6" position="{pic6.pos}" zPosition="4" size="144,144" pixmap="{dev}mainpic/pic_6.jpg" transparent="1" alphatest="on" />
229 <widget name="Pic7" position="{pic7.pos}" zPosition="4" size="144,144" pixmap="{dev}mainpic/pic_7.jpg" transparent="1" alphatest="on" />
230 <widget name="Pic8" position="{pic8.pos}" zPosition="4" size="144,144" pixmap="{dev}mainpic/pic_8.jpg" transparent="1" alphatest="on" />
231 <widget name="Pic9" position="{pic9.pos}" zPosition="5" size="144,144" pixmap="{dev}mainpic/pic_9.jpg" transparent="1" alphatest="on" />
232 <widget name="Pic10" position="{pic10.pos}" zPosition="5" size="144,144" pixmap="{dev}mainpic/pic_10.jpg" transparent="1" alphatest="on" />
233 <widget name="Pic11" position="{pic11.pos}" zPosition="5" size="144,144" pixmap="{dev}mainpic/pic_11.jpg" transparent="1" alphatest="on" />
234 <widget name="Pic12" position="{pic12.pos}" zPosition="5" size="144,144" pixmap="{dev}mainpic/pic_12.jpg" transparent="1" alphatest="on" />
235 <ePixmap pixmap="skin_default/buttons/button_red.png" position="30,495" size="15,16" alphatest="on" />
236 <ePixmap pixmap="skin_default/buttons/button_green.png" position="180,495" size="15,16" alphatest="on" />
237 <ePixmap pixmap="skin_default/buttons/button_yellow.png" position="360,495" size="15,16" alphatest="on" />
238 <ePixmap pixmap="skin_default/buttons/button_blue.png" position="520,495" size="15,16" alphatest="on" />
239 <widget source="key_red" render="Label" position="50,490" zPosition="1" size="350,25" font="Regular;22" halign="left" transparent="1" />
240 <widget source="key_green" render="Label" position="200,490" zPosition="1" size="250,25" font="Regular;22" halign="left" transparent="1" />
241 <widget source="key_yellow" render="Label" position="380,490" zPosition="1" size="350,25" font="Regular;22" halign="left" transparent="1" />
242 <widget source="key_blue" render="Label" position="540,490" zPosition="1" size="350,25" font="Regular;22" halign="left" transparent="1" />
243 </screen>"""
244
245#<widget source="job_progressbar" render="Progress" position="10,520" size="{progress.size}" borderWidth="1" backgroundColor="#254f7497" />
246#<widget source="job_progresslabel" render="Label" position="130,519" zPosition="6" font="Regular;18" halign="center" transparent="1" size="330,14" foregroundColor="#000000" />
247
248 def __init__(self, session):
249 self.session = session
250 global selLink
251 global maxpage
252 offsety = config.plugins.picasa.max_offsety.value
253 # allgemeiner Defaultlink
254 selLink = "http://picasaweb.google.com/data/feed/base/all?alt=rss&kind=photo&access=public&tag=tiere&filter=1&hl=de"
255 #switch automatic to current skin
256 current_w = getDesktop(0).size().width()
257 current_h = getDesktop(0).size().height()
258 print "DESKTOPsize is",current_w,current_h
259
260 # define the start koordinates and size
261 if current_w == 1280:
262 size_w = 700
263 size_h = 550
264 else:
265 size_w = 700
266 size_h = 550
267
268 pos_w = (current_w - size_w)/2
269 pos_h = (current_h - size_h)/2 + offsety
270
271 # calculate Skin koordinates
272 font = "Regular;18"
273 green_pos = 20
274 blue_pos = 225
275 green2_pos = 20
276 blue2_pos = 225
277
278 offset = 30
279 offsett = 0
280
281 pic1posl = 10 + offset
282 pic1post = 10 + offsett
283 pic1aposl = 6 + offset
284 pic1apost = 144 + offsett
285 pic2posl = 170 + offset
286 pic2post = 10 + offsett
287 pic2aposl = 166 + offset
288 pic2apost = 144 + offsett
289 pic3posl = 330 + offset
290 pic3post = 10 + offsett
291 pic3aposl = 326 + offset
292 pic3apost = 144 + offsett
293 pic4posl = 490 + offset
294 pic4post = 10 + offsett
295 pic4aposl = 486 + offset
296 pic4apost = 144 + offsett
297 pic5posl = 10 + offset
298 pic5post = 170 + offsett
299 pic5aposl = 6 + offset
300 pic5apost = 304 + offsett
301 pic6posl = 170 + offset
302 pic6post = 170 + offsett
303 pic6aposl = 166 + offset
304 pic6apost = 304 + offsett
305 pic7posl = 330 + offset
306 pic7post = 170 + offsett
307 pic7aposl = 326 + offset
308 pic7apost = 304 + offsett
309 pic8posl = 490 + offset
310 pic8post = 170 + offsett
311 pic8aposl = 486 + offset
312 pic8apost = 304 + offsett
313 pic9posl = 10 + offset
314 pic9post = 330 + offsett
315 pic9aposl = 6 + offset
316 pic9apost = 464 + offsett
317 pic10posl = 170 + offset
318 pic10post = 330 + offsett
319 pic10aposl = 166 + offset
320 pic10apost = 464 + offsett
321 pic11posl = 330 + offset
322 pic11post = 330 + offsett
323 pic11aposl = 326 + offset
324 pic11apost = 464 + offsett
325 pic12posl = 490 + offset
326 pic12post = 330 + offsett
327 pic12aposl = 486 + offset
328 pic12apost = 464 + offsett
329
330 # set Skinvariables
331 devicepath = config.plugins.picasa.Device.value
332 self.dict = {
333 'dev': devicepath,
334 'font': font,
335 'picasa.size': "%i,%i"%(size_w,size_h),
336 'picasa.pos': "%i,%i"%(pos_w,pos_h),
337 'progress.size': "%i,%i"%(size_w -20,22),
338 'green.pos': "%i,5"%(green_pos),
339 'blue.pos': "%i,5"%(blue_pos),
340 'green2.pos': "%i,5"%(green2_pos),
341 'blue2.pos': "%i,5"%(blue2_pos),
342 'pic1.pos': "%i,%i"%(pic1posl,pic1post),
343 'pic2.pos': "%i,%i"%(pic2posl,pic2post),
344 'pic3.pos': "%i,%i"%(pic3posl,pic3post),
345 'pic4.pos': "%i,%i"%(pic4posl,pic4post),
346 'pic5.pos': "%i,%i"%(pic5posl,pic5post),
347 'pic6.pos': "%i,%i"%(pic6posl,pic6post),
348 'pic7.pos': "%i,%i"%(pic7posl,pic7post),
349 'pic8.pos': "%i,%i"%(pic8posl,pic8post),
350 'pic9.pos': "%i,%i"%(pic9posl,pic9post),
351 'pic10.pos': "%i,%i"%(pic10posl,pic10post),
352 'pic11.pos': "%i,%i"%(pic11posl,pic11post),
353 'pic12.pos': "%i,%i"%(pic12posl,pic12post),
354 'pic1a.pos': "%i,%i"%(pic1aposl,pic1apost),
355 'pic2a.pos': "%i,%i"%(pic2aposl,pic2apost),
356 'pic3a.pos': "%i,%i"%(pic3aposl,pic3apost),
357 'pic4a.pos': "%i,%i"%(pic4aposl,pic4apost),
358 'pic5a.pos': "%i,%i"%(pic5aposl,pic5apost),
359 'pic6a.pos': "%i,%i"%(pic6aposl,pic6apost),
360 'pic7a.pos': "%i,%i"%(pic7aposl,pic7apost),
361 'pic8a.pos': "%i,%i"%(pic8aposl,pic8apost),
362 'pic9a.pos': "%i,%i"%(pic9aposl,pic9apost),
363 'pic10a.pos': "%i,%i"%(pic10aposl,pic10apost),
364 'pic11a.pos': "%i,%i"%(pic11aposl,pic11apost),
365 'pic12a.pos': "%i,%i"%(pic12aposl,pic12apost),
366 }
367
368 self.skin = applySkinVars(PicasaMain.skin,self.dict)
369 Screen.__init__(self, session)
370
371 file = open("/proc/stb/info/model", "r")
372 box = file.readline().strip()
373 file.close()
374
375 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "ColorActions", "MovieSelectionActions", "MenuActions", "MoviePlayerActions", "ChannelSelectBaseActions", "NumberActions"],
376 {
377 "cancel": self.closePicasa,
378 "left": self.left,
379 "right": self.right,
380 "up": self.up,
381 "down": self.down,
382 "red": self.pressed_redkey,
383 "green": self.Select,
384 "yellow": self.otherSelect,
385 "blue": self.SlideShow,
386 "menu": self.PicSetupMenu,
387 "ok": self.loadPicture
388 }, -1)
389
390
391 self["Pic1"] = Pixmap()
392 self["Pic2"] = Pixmap()
393 self["Pic3"] = Pixmap()
394 self["Pic4"] = Pixmap()
395 self["Pic5"] = Pixmap()
396 self["Pic6"] = Pixmap()
397 self["Pic7"] = Pixmap()
398 self["Pic8"] = Pixmap()
399 self["Pic9"] = Pixmap()
400 self["Pic10"] = Pixmap()
401 self["Pic11"] = Pixmap()
402 self["Pic12"] = Pixmap()
403
404 self["Pic1a"] = Pixmap()
405 self["Pic1a"].show()
406 self["Pic2a"] = Pixmap()
407 self["Pic2a"].hide()
408 self["Pic3a"] = Pixmap()
409 self["Pic3a"].hide()
410 self["Pic4a"] = Pixmap()
411 self["Pic4a"].hide()
412 self["Pic5a"] = Pixmap()
413 self["Pic5a"].hide()
414 self["Pic6a"] = Pixmap()
415 self["Pic6a"].hide()
416 self["Pic7a"] = Pixmap()
417 self["Pic7a"].hide()
418 self["Pic8a"] = Pixmap()
419 self["Pic8a"].hide()
420 self["Pic9a"] = Pixmap()
421 self["Pic9a"].hide()
422 self["Pic10a"] = Pixmap()
423 self["Pic10a"].hide()
424 self["Pic11a"] = Pixmap()
425 self["Pic11a"].hide()
426 self["Pic12a"] = Pixmap()
427 self["Pic12a"].hide()
428
429 self["key_red"] = StaticText(_("my Pic"))
430 self["key_green"] = StaticText(_("myPic more"))
431 self["key_yellow"] = StaticText(_("other Pic"))
432 self["key_blue"] = StaticText(_("SlideShow"))
433
434 self.pic = 1
435 self.download = 1
436 self.seite = 1
437
438 maxpage = 1
439 self.page = 1
440 self.focus = 1 # 1 = MainPic, 2 = MyPic 3 = otherPic
441 self.outpath = "mainpic"
442 #self.mypic_select = 0
443
444 devicepath = config.plugins.picasa.Device.value
445 print "[Picasa] Devicepath=" + devicepath
446 self.ReadMain()
447
448#------------------------------------------------------------------------------------------
449 def pressed_redkey(self):
450 global curpage
451 curpage = 1
452 self.mypic_select = 0
453 self.MyPic_now()
454#------------------------------------------------------------------------------------------
455 def SlideShow(self):
456 self.PicDownloadmain()
457 self.session.open(View_Slideshow, 0, True)
458#------------------------------------------------------------------------------------------
459
460 def loadPicture(self):
461 devicepath = config.plugins.picasa.Device.value
462
463 path = devicepath +"mainpicBig/"
464 if os.path.exists(devicepath +"mainpicBig") is False:
465 os.system("mkdir -p " + devicepath + "mainpicBig")
466 else:
467 os.system("rm " + devicepath + "mainpicBig/*")
468
469 # tausche die Aufloesung und erhoehe sie
470 self.outpath = "mainpic"
471 self.pixel = config.plugins.picasa.max_picpixel.value
472 CpString = "sed -e 's:s144-c:s" + self.pixel +":g' -i " + devicepath + self.outpath + "/pic_" + str(self.pic) + ".lnk"
473 os.system(CpString)
474
475 if fileExists(devicepath + self.outpath + "/pic_" + str(self.pic) + ".lnk"):
476 file = open(devicepath + self.outpath + "/pic_" + str(self.pic) + ".lnk", "r")
477 BigUrl = file.readline().strip()
478 print "[Picasa] BigUrl" + BigUrl
479 file.close()
480
481 self.LoadMainPicBig(BigUrl, self.pic)
482 filelist = devicepath + "mainpicBig/pic_" + str(self.pic) + ".jpg"
483 self.session.open(PicView, filelist, 0, path, False)
484
485#------------------------------------------------------------------------------------------
486 def Preview(self):
487 devicepath = config.plugins.picasa.Device.value
488 path = devicepath + self.outpath + "/"
489 filelist = FileList(path, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)")
490 self.session.open(PicView, filelist.getFileList(), 0, path, True)
491
492#------------------------------------------------------------------------------------------
493 def down(self):
494 if self.pic <= 8:
495 self.pic = self.pic + 4
496 self.setPicture(self.pic)
497
498#------------------------------------------------------------------------------------------
499 def up(self):
500 if self.pic >= 5:
501 self.pic = self.pic - 4
502 self.setPicture(self.pic)
503
504#------------------------------------------------------------------------------------------
505 def left(self):
506 if self.pic > 1:
507 self.pic = self.pic - 1
508 self.setPicture(self.pic)
509
510#------------------------------------------------------------------------------------------
511 def right(self):
512 if self.pic < 12:
513 self.pic = self.pic + 1
514 self.setPicture(self.pic)
515
516#------------------------------------------------------------------------------------------
517 def PicSetupMenu(self):
518 self.session.open(PicSetup)
519
520#------------------------------------------------------------------------------------------
521 def closePicasa(self):
522 if str(config.plugins.picasa.remove.value) == "0":
523 devicepath = config.plugins.picasa.Device.value
524 job = "rm -r " + devicepath + "mainpic"
525 os.system(job)
526 job = "rm -r " + devicepath + "mypic"
527 os.system(job)
528 job = "rm -r " + devicepath + "otherpic"
529 os.system(job)
530 job = "rm -r " + devicepath + "mainpicBig"
531 os.system(job)
532
533 os.system("rm -r /usr/lib/enigma2/python/Plugins/Extensions/Picasa/private.info")
534 os.system("rm -r /usr/lib/enigma2/python/Plugins/Extensions/Picasa/public.info")
535 os.system("rm -r /usr/lib/enigma2/python/Plugins/Extensions/Picasa/rss.info")
536 self.close()
537
538#------------------------------------------------------------------------------------------
539 def Select(self):
540 global selLink
541 global curpage
542 global loadpicnow
543
544 self.focus = 2
545 curpage = 1
546 self.seite = 1
547 loadpicnow = 0
548 self.mypic_select = 1
549 selLink = "http://picasaweb.google.com/lh/view?feat=tags&psc=G&filter=1&tags=tiere#" # Tiere als Default
550 print "[Picasa Curpic]"
551
552 if str(config.plugins.picasa.remove.value) == "1": # Bilder nicht loeschen
553 if os.path.exists("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/curpic") is True:
554 file = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/curpic", "r" )
555 self.curpicname = file.readline().strip()
556 print "[Picasa Curpic] =" + self.curpicname
557 file.close()
558 message = "%s %s" % (self.curpicname, _("\nist bereits im Cache vorhanden!\nSoll ein anderes Webalbum geladen werden?"))
559 self.session.openWithCallback(self.load_now, MessageBox, message, MessageBox.TYPE_YESNO)
560 else:
561 self.session.openWithCallback(self.SelectStatus, SelectGroup, self.focus)
562 else:
563 self.session.openWithCallback(self.SelectStatus, SelectGroup, self.focus)
564
565 def load_now(self, answer):
566 global selLink
567 global loadpicnow
568 if answer == True:
569 self.session.openWithCallback(self.SelectStatus, SelectGroup, self.focus)
570 else:
571 if os.path.exists("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/Link/" + self.curpicname) is True:
572 file = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/Link/" + self.curpicname, "r")
573 selLink = file.readline().strip()
574 print "[Picasa] select selLink= " + selLink
575 file.close()
576 loadpicnow = 1
577 #self.mypic_select = 1
578 self.MyPic_select()
579
580#------------------------------------------------------------------------------------------
581
582 def otherSelect(self):
583 global selLink
584 global curpage
585 self.focus = 3
586 curpage = 1
587 self.seite = 1
588 self.mypic_select = 0
589 selLink = "http://picasaweb.google.com/lh/view?feat=tags&psc=G&filter=1&tags=tiere#" ## Tiere als Default
590 self.session.openWithCallback(self.otherSelectStatus, SelectGroup, self.focus)
591
592
593 def SelectStatus(self):
594 global selLink
595 print "[Picasa SelectStatus Link] =" + selLink
596 if selLink == "stop":
597 print "[Picasa Group gestopt]"
598 else:
599 print "[Picasa Group select]"
600 #self.MyPic()
601 self.MyPic_select()
602
603 def otherSelectStatus(self):
604 global selLink
605 print "[Picasa otherSelectStatus Link] =" + selLink
606 if selLink == "stop":
607 print "[Picasa Groupother gestopt]"
608 else:
609 print "[Picasa Group selectother]"
610 self.OtherPic()
611 self.otherMyPic_select() # zurueck in die Skinanzeige
612
613
614#------------------------------------------------------------------------------------------
615 def setPicture(self,counter):
616 self["Pic1a"].hide()
617 self["Pic2a"].hide()
618 self["Pic3a"].hide()
619 self["Pic4a"].hide()
620 self["Pic5a"].hide()
621 self["Pic6a"].hide()
622 self["Pic7a"].hide()
623 self["Pic8a"].hide()
624 self["Pic9a"].hide()
625 self["Pic10a"].hide()
626 self["Pic11a"].hide()
627 self["Pic12a"].hide()
628
629 if counter == 1:
630 self["Pic1a"].show()
631 if counter == 2:
632 self["Pic2a"].show()
633 if counter == 3:
634 self["Pic3a"].show()
635 if counter == 4:
636 self["Pic4a"].show()
637 if counter == 5:
638 self["Pic5a"].show()
639 if counter == 6:
640 self["Pic6a"].show()
641 if counter == 7:
642 self["Pic7a"].show()
643 if counter == 8:
644 self["Pic8a"].show()
645 if counter == 9:
646 self["Pic9a"].show()
647 if counter == 10:
648 self["Pic10a"].show()
649 if counter == 11:
650 self["Pic11a"].show()
651 if counter == 12:
652 self["Pic12a"].show()
653
654#------------------------------------------------------------------------------------------
655 def ReadMain(self):
656 global box
657 devicepath = config.plugins.picasa.Device.value
658 print "[Picasa] Seite wurde geladen"
659 bild = 0
660
661 if self.focus == 1: # MainPic
662 self.outpath = "mainpic"
663 fread = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/public.info", "r" )
664 if self.focus == 2: # MyPic
665 self.outpath = "mypic"
666 fread = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/private.info", "r" )
667 if self.focus == 3: # otherPic
668 self.outpath = "otherpic"
669 fread = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/other.info", "r" )
670
671 if os.path.exists(devicepath + self.outpath) is False:
672 os.system("mkdir -p " + devicepath + self.outpath)
673
674 for line in fread:
675 zeile = line.lstrip()
676
677 # suche Link aus der Seite fuer die Thumbnails in 144x144
678 found_link = zeile.find('height="144" src="')
679
680 if found_link != -1:
681 found_link = zeile.find('http://')
682 bild = bild + 1
683
684 if box <> "dm500hd":
685 evfd.getInstance().vfd_write_string("Picture " + str(bild))
686
687 LinkThumb = zeile[found_link:-2]
688 fwrite = open(devicepath + self.outpath + "/pic_" + str(bild) + ".lnk", "w" )
689 fwrite.write(LinkThumb + '\n')
690 fwrite.close()
691
692 print "[Picasa]" + str(LinkThumb)
693 self.LoadMainPic(LinkThumb,bild)
694
695#------------------------------------------------------------------------------------------
696 def MyPic_now(self):
697 global selLink
698 global maxpage
699 if selLink == "stop":
700 return
701
702 print "[Picasa] MyPiself.mypic_select=" + str(self.mypic_select)
703 if self.mypic_select == 0:
704 if not fileExists("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/myLink.lnk"):
705 session.open(MessageBox, _("cannot found 'myLink.lnk', please define it!"), type = MessageBox.TYPE_INFO, timeout = 10)
706 else:
707 file = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/myLink.lnk", "r")
708 selLink = file.readline().strip()
709 file.close()
710
711 print "[Picasa] MyPic_now maxpage vorher" + str(maxpage)
712 self.focus = 2
713 self.session.openWithCallback(self.PageStatus, PicasaMyPic, self.download, self.focus, maxpage, self.seite)
714
715#------------------------------------------------------------------------------------------
716 def MyPic_select(self):
717 global selLink
718 global maxpage
719 if selLink == "stop":
720 return
721 print "[Picasa MyPic_select] =" + selLink
722
723 self.focus = 2
724 print "[Picasa] MyPic_select ruft PicasaMyPic"
725 self.session.openWithCallback(self.PageStatus, PicasaMyPic, self.download, self.focus, maxpage, self.seite)
726
727#------------------------------------------------------------------------------------------
728 def otherMyPic_select(self):
729 global selLink
730 global maxpage
731 if selLink == "stop":
732 return
733 print "[Picasa otherMyPic_select] =" + selLink
734
735 self.focus = 3
736 print "[Picasa] otherMyPic_now ruft PicasaMyPic"
737 self.session.openWithCallback(self.PageStatus, PicasaMyPic, self.download, self.focus, maxpage, self.seite)
738
739
740#----------------- new load now self -------------------------------------------------------------------------
741 def OtherPic(self):
742 global selLink
743 global maxpage
744 global box
745 devicepath = config.plugins.picasa.Device.value
746 self.focus = 3
747 #max_otherpic = 6
748 max_otherpic = config.plugins.picasa.max_otherpic.value
749
750 #url = "http://picasaweb.google.com/113655494029816075097/AAF?authkey=Gv1sRgCKifw7rNts75Zg#"
751 url = selLink
752 ret = system("checknet picasaweb.google.com")
753 bild = 0
754 total = 0
755
756 #self["job_progressbar"].value = int(200)
757 #self["job_progresslabel"].text = "Bilder 10 / 100"
758
759 # starten mit der Ansicht "eigene Fotos"
760 if box <> "dm8000":
761 evfd.getInstance().vfd_write_string("downloading... ")
762
763 if ret == 0:
764 h = urllib.urlretrieve(url, "/usr/lib/enigma2/python/Plugins/Extensions/Picasa/rss.info")
765 else:
766 print "picasaweb.google.com eigene Bilder nicht erreichbar"
767 session.open(MessageBox, _("picasaweb.google.com is unreachable."), type = MessageBox.TYPE_INFO, timeout = 10)
768
769 self.outpath = "otherpic"
770 fread = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/rss.info", "r" )
771
772 if os.path.exists(devicepath + self.outpath) is False:
773 os.system("mkdir -p " + devicepath + self.outpath)
774
775 print "[Picasa OtherPic] Seite wird geladen (nowself)"
776 if box <> "dm8000":
777 evfd.getInstance().vfd_write_string("filtering...")
778
779 # SED ist beim Filtern schneller
780 os.system("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/rss.sh")
781 print "[Picasa OtherPic] Seite wurde geladen"
782
783 self.page = 1
784 self.totalpath = devicepath + self.outpath + "/" + str(self.page)
785 CpString = "mkdir -p " + self.totalpath
786 os.system(CpString)
787
788 fread = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/rss.info", "r" )
789 for line in fread:
790 zeile = line.lstrip()
791 found_jpg = zeile.find('s128')
792
793 if found_jpg != -1:
794 bild = bild + 1
795 total = total + 1
796 if box <> "dm8000":
797 evfd.getInstance().vfd_write_string("Picture " + str(total))
798 if bild >= 13: # naechste Seite anlegen
799 self.page = self.page + 1
800 if self.page >= (max_otherpic + 1):
801 break
802 bild = 1
803 self.totalpath = devicepath + self.outpath + "/" + str(self.page)
804 CpString = "mkdir -p " + self.totalpath
805 os.system(CpString)
806
807 LinkThumb = zeile
808 print "[Picasa]" + LinkThumb
809
810 fwrite = open(devicepath + self.outpath + "/" + str(self.page) + "/pic_" + str(bild) + ".lnk", "w" )
811 #fwrite.write(LinkThumb + '\n')
812 fwrite.write(LinkThumb)
813 fwrite.close()
814 self.LoadMainPic2(LinkThumb,bild)
815
816 # Dummy Bilder ins View Verzeichnis kopieren wenn nicht 12 erreicht werden
817 CpString = "cp -f /usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/* " + devicepath + self.outpath
818 os.system(CpString)
819
820 # die ersten 12 Bilder ins View Verzeichnis kopieren
821 CpString = "cp -f " + devicepath + self.outpath + "/1/* " + devicepath + self.outpath
822 os.system(CpString)
823
824 self.check_jpg(self.outpath) # pruefe ob es ein jpg ist
825 maxpage = self.page
826
827#------------------------- new load now self -----------------------------------------------------------------
828 def LoadMainPic2(self,url,counter):
829 # lade die Vorschaubilder und lege sie ab
830 devicepath = config.plugins.picasa.Device.value
831 self.previewPath =devicepath + self.outpath + "/" + str(self.page) + "/pic_" + str(counter) + ".jpg"
832 h = urllib.urlretrieve(url, self.previewPath)
833
834#-------------------------- new load now self ----------------------------------------------------------------
835 def check_jpg(self, path):
836 # the first two bytes FF and D8 mark a jpeg file
837 devicepath = config.plugins.picasa.Device.value
838 x = 0
839 while x < 12:
840 x = x + 1
841 self.filelist = devicepath + path + "/pic_" + str(x) + ".jpg"
842 print "[Picasa] check Picload " + str(x)
843
844 data = open(self.filelist, "r+")
845 data.seek(1)
846 byte1 = data.read(1) # 216 D8
847 byte2 = data.read(1) # 255 FF
848 data.close()
849 if ord(byte1) != 216 or ord(byte2) != 255:
850 print "[Picasa] Bildfehler, wird korregiert"
851 CpString = "cp -f /usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/pic_" + str(x) + ".jpg " + devicepath + self.outpath
852 #print CpString
853 os.system(CpString)
854
855
856#---------- Seitenwechsel MyPic --------------------------------------------------------------------------------
857 def PageStatus(self):
858 global page # next oder prev fuer Steuerung
859 global curpage # aktuelle Seite
860 global maxpage # maximale Seite
861
862 #maxpage = self.maxpage # max Seitenzaehler fuer Anzeige
863 devicepath = config.plugins.picasa.Device.value
864 print "[Picasa self.focus] " + str(self.focus) + " " + str(maxpage) + " " + str(curpage)
865
866 if self.focus == 2:
867 self.picpath = "mypic"
868 if self.focus == 3:
869 self.picpath = "otherpic"
870
871 print "[Picasa] in der PageStatus=" + page
872
873 if page == "next" or page == "prev":
874 if page == "next":
875 page = "none"
876 self.seite = self.seite + 1
877 self.curPath = devicepath + self.picpath + "/" + str(self.seite)
878 print "[Picasa] self.seite=" + str(self.seite)
879 print "[Picasa] os.path.exists=" + self.curPath
880 if os.path.exists(self.curPath) is True:
881 # Dummy Bilder ins View Verzeichnis kopieren wenn nicht 12 erreicht werden
882 CpString = "cp -f /usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/* " + devicepath + self.picpath
883 os.system(CpString)
884 # die naechsten 12 Bilder ins View Verzeichnis kopieren
885 print "[Picasa]Kopieren von=" + devicepath + self.picpath + "/" + str(self.seite) + "/* " + devicepath + self.picpath
886 CpString = "cp -f " + devicepath + self.picpath + "/" + str(self.seite) + "/* " + devicepath + self.picpath
887 os.system(CpString)
888 self.checkmain_jpg(self.picpath) # pruefe ob es ein jpg ist
889 else:
890 self.seite = self.seite - 1
891
892 self.download = 0 # keine Bilder online laden
893 curpage = self.seite
894
895 if self.picpath == "mypic":
896 print "[Picasa] in der Next Aufruf MyPic"
897 self.MyPic_now()
898 if self.picpath == "otherpic":
899 print "[Picasa] in der Next Aufruf otherMyPic"
900 self.otherMyPic_select()
901
902 if page == "prev":
903 page = "none"
904 self.seite = self.seite - 1
905 self.curPath = devicepath + self.picpath + "/" + str(self.seite)
906 if os.path.exists(self.curPath) is True:
907 # die vorherigen 12 Bilder ins View Verzeichnis kopieren
908 CpString = "cp -f " + devicepath + self.picpath + "/" + str(self.seite) + "/* " + devicepath + self.picpath
909 os.system(CpString)
910 self.checkmain_jpg(self.picpath) # pruefe ob es ein jpg ist
911 else:
912 self.seite = self.seite + 1
913
914 curpage = self.seite
915 self.download = 0 # keine Bilder online laden
916
917 if self.picpath == "mypic":
918 print "[Picasa] in der Next Aufruf MyPic"
919 self.MyPic_now()
920 if self.picpath == "otherpic":
921 print "[Picasa] in der Next Aufruf otherMyPic"
922 self.otherMyPic_select()
923 else:
924 self.download = 1 # Bilder online laden
925
926#------------------------------------------------------------------------------------------
927 def LoadMainPic(self,url,counter):
928 # lade die Vorschaubilder und lege sie ab
929 devicepath = config.plugins.picasa.Device.value
930 self.previewPath = devicepath + self.outpath + "/pic_" + str(counter) + ".jpg"
931 h = urllib.urlretrieve(url, self.previewPath)
932
933#------------------------------------------------------------------------------------------
934 def LoadMainPicBig(self,url,counter):
935 # lade die groessen Bilder und lege sie ab
936 devicepath = config.plugins.picasa.Device.value
937 h = urllib.urlretrieve(url, devicepath + "mainpicBig/pic_" + str(counter) + ".jpg")
938
939#------------------------------------------------------------------------------------------
940 def checkmain_jpg(self, path):
941 # the first two bytes FF and D8 mark a jpeg file
942 devicepath = config.plugins.picasa.Device.value
943 self.picpath = path
944 x = 0
945 while x < 12:
946 x = x + 1
947 self.filelist = devicepath + self.picpath + "/pic_" + str(x) + ".jpg"
948 print "[Picasa] check Main-JPG " + str(x)
949
950 data = open(self.filelist, "r+")
951 data.seek(1)
952 byte1 = data.read(1) # 216 D8
953 byte2 = data.read(1) # 255 FF
954 data.close()
955 if ord(byte1) != 216 or ord(byte2) != 255:
956 print "[Picasa] Bildfehler, wird korregiert"
957 CpString = "cp -f /usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/pic_" + str(x) + ".jpg " + devicepath + self.picpath
958 #print CpString
959 os.system(CpString)
960
961#------------------------------------------------------------------------------------------
962 def PicDownloadmain(self):
963 global box
964 devicepath = config.plugins.picasa.Device.value
965 path = devicepath + "Slideshow/"
966 print "[Picasa] PicDownloadmain Path=" + path
967 #config.plugins.mc_pp.lastDir.save
968 if os.path.exists(devicepath + "Slideshow") is False:
969 os.system("mkdir -p " + devicepath + "Slideshow")
970 else:
971 os.system("rm " + path + "*")
972
973 self.outpath = "mainpic"
974
975 self.pixel = config.plugins.picasa.max_picpixel.value
976
977 picmax = 12
978 picdef = config.plugins.picasa.max_otherpic.value
979 x = 0
980 picnr = 0
981 seite = 0
982 seitenr = 0
983 prenr = "a"
984 maxseite = config.plugins.picasa.max_otherpic.value
985 maxseite = 1
986
987 while x < maxseite:
988 x = x + 1
989 if os.path.exists(devicepath + self.outpath) is True:
990 #print "[Picasa] Path=" + devicepath + self.outpath + "/"
991 picnr = 0
992 seite = seite + 1
993
994 while picnr < picmax:
995 picnr = picnr + 1
996 seitenr = seitenr + 1
997 if box <> "dm8000":
998 evfd.getInstance().vfd_write_string("Picture " + str(picnr))
999
1000 sourcepath = devicepath + self.outpath + "/" + "/pic_" + str(picnr) + ".lnk"
1001 if fileExists(sourcepath):
1002 CpString = "sed -e 's:s144-c:s" + self.pixel +":g' -i " + sourcepath
1003 os.system(CpString)
1004 file = open(sourcepath, "r")
1005 BigUrl = file.readline().strip()
1006 print "[Picasa] BigUrl" + BigUrl
1007 file.close()
1008 if seitenr == 10:
1009 prenr = "b"
1010 if seitenr == 20:
1011 prenr = "c"
1012 if seitenr == 10:
1013 prenr = "d"
1014 if seitenr == 30:
1015 prenr = "e"
1016 if seitenr == 40:
1017 prenr = "f"
1018 if seitenr == 50:
1019 prenr = "g"
1020 if seitenr == 60:
1021 prenr = "h"
1022 if seitenr == 70:
1023 prenr = "i"
1024 h = urllib.urlretrieve(BigUrl, devicepath + "Slideshow/pic_" + prenr + str(seitenr) + ".jpg")
1025
1026#------------------------------------------------------------------------------------------
1027#------------------------------ Picasa Eigene Fotos ---------------------------------------
1028#------------------------------------------------------------------------------------------
1029
1030class PicasaMyPic(Screen):
1031 devicepath = config.plugins.picasa.Device.value
1032
1033 skin = """
1034 <screen name="PicasaMySkin" position="{picasa.pos}" size="{picasa.size}" title="Picasa" backgroundColor="#000000" >
1035 <widget name="Pic1a" position="{pic1a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1036 <widget name="Pic2a" position="{pic2a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1037 <widget name="Pic3a" position="{pic3a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1038 <widget name="Pic4a" position="{pic4a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1039 <widget name="Pic5a" position="{pic5a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1040 <widget name="Pic6a" position="{pic6a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1041 <widget name="Pic7a" position="{pic7a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1042 <widget name="Pic8a" position="{pic8a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1043 <widget name="Pic9a" position="{pic9a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1044 <widget name="Pic10a" position="{pic10a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1045 <widget name="Pic11a" position="{pic11a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1046 <widget name="Pic12a" position="{pic12a.pos}" zPosition="2" size="149,25" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/Picasa/green-big.png" alphatest="on" />
1047 <widget name="MyPic1" position="{mypic1.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_1.jpg" transparent="1" alphatest="on" />
1048 <widget name="MyPic2" position="{mypic2.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_2.jpg" transparent="1" alphatest="on" />
1049 <widget name="MyPic3" position="{mypic3.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_3.jpg" transparent="1" alphatest="on" />
1050 <widget name="MyPic4" position="{mypic4.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_4.jpg" transparent="1" alphatest="on" />
1051 <widget name="MyPic5" position="{mypic5.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_5.jpg" transparent="1" alphatest="on" />
1052 <widget name="MyPic6" position="{mypic6.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_6.jpg" transparent="1" alphatest="on" />
1053 <widget name="MyPic7" position="{mypic7.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_7.jpg" transparent="1" alphatest="on" />
1054 <widget name="MyPic8" position="{mypic8.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_8.jpg" transparent="1" alphatest="on" />
1055 <widget name="MyPic9" position="{mypic9.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_9.jpg" transparent="1" alphatest="on" />
1056 <widget name="MyPic10" position="{mypic10.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_10.jpg" transparent="1" alphatest="on" />
1057 <widget name="MyPic11" position="{mypic11.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_11.jpg" transparent="1" alphatest="on" />
1058 <widget name="MyPic12" position="{mypic12.pos}" zPosition="6" size="144,144" pixmap="{dev}/pic_12.jpg" transparent="1" alphatest="on" />
1059 <ePixmap pixmap="skin_default/buttons/button_red.png" position="30,495" size="15,16" alphatest="on" />
1060 <ePixmap pixmap="skin_default/buttons/button_green.png" position="160,495" size="15,16" alphatest="on" />
1061 <ePixmap pixmap="skin_default/buttons/button_blue.png" position="360,495" size="15,16" alphatest="on" />
1062 <widget source="key_red" render="Label" position="50,490" zPosition="1" size="350,25" font="Regular;22" halign="left" transparent="1" />
1063 <widget source="key_green" render="Label" position="180,490" zPosition="1" size="250,25" font="Regular;22" halign="left" transparent="1" />
1064 <widget source="key_yellow" render="Label" position="380,490" zPosition="1" size="450,25" font="Regular;22" halign="left" transparent="1" />
1065 <widget source="key_blue" render="Label" position="550,490" zPosition="1" size="450,25" font="Regular;22" halign="left" transparent="1" />
1066 <widget source="Seitenzeile" render="Label" position="585,525" size="95,23" foregroundColor="#ff3030" font="Regular;20" transparent="1"/>
1067 </screen>"""
1068
1069 def __init__(self, session, download, Fokus, smaxpage, spage):
1070 self.session = session
1071 global curpage
1072 global maxpage
1073 global loadpicnow
1074 #self.maxpage = smaxpage
1075 self.page = spage
1076
1077 #switch automatic to current skin
1078 current_w = getDesktop(0).size().width()
1079 current_h = getDesktop(0).size().height()
1080 print "[Picasa] DESKTOPsize is",current_w,current_h
1081
1082 # define the start koordinates and size
1083 if current_w == 1280:
1084 size_w = 700
1085 size_h = 550
1086 else:
1087 size_w = 700
1088 size_h = 550
1089
1090 offsety = config.plugins.picasa.max_offsety.value
1091 pos_w = (current_w - size_w)/2
1092 pos_h = (current_h - size_h)/2 + offsety
1093
1094 # calculate Skin koordinates
1095 font = "Regular;18"
1096 green_pos = 20
1097 blue_pos = 225
1098 green2_pos = 20
1099 blue2_pos = 225
1100
1101 offset = 30
1102 offsett = 0
1103
1104 pic1posl = 10 + offset
1105 pic1post = 10 + offsett
1106 pic1aposl = 6 + offset
1107 pic1apost = 144 + offsett
1108 pic2posl = 170 + offset
1109 pic2post = 10 + offsett
1110 pic2aposl = 166 + offset
1111 pic2apost = 144 + offsett
1112 pic3posl = 330 + offset
1113 pic3post = 10 + offsett
1114 pic3aposl = 326 + offset
1115 pic3apost = 144 + offsett
1116 pic4posl = 490 + offset
1117 pic4post = 10 + offsett
1118 pic4aposl = 486 + offset
1119 pic4apost = 144 + offsett
1120 pic5posl = 10 + offset
1121 pic5post = 170 + offsett
1122 pic5aposl = 6 + offset
1123 pic5apost = 304 + offsett
1124
1125 pic6posl = 170 + offset
1126 pic6post = 170 + offsett
1127 pic6aposl = 166 + offset
1128 pic6apost = 304 + offsett
1129
1130 pic7posl = 330 + offset
1131 pic7post = 170 + offsett
1132 pic7aposl = 326 + offset
1133 pic7apost = 304 + offsett
1134
1135 pic8posl = 490 + offset
1136 pic8post = 170 + offsett
1137 pic8aposl = 486 + offset
1138 pic8apost = 304 + offsett
1139
1140 pic9posl = 10 + offset
1141 pic9post = 330 + offsett
1142 pic9aposl = 6 + offset
1143 pic9apost = 464 + offsett
1144
1145 pic10posl = 170 + offset
1146 pic10post = 330 + offsett
1147 pic10aposl = 166 + offset
1148 pic10apost = 464 + offsett
1149
1150 pic11posl = 330 + offset
1151 pic11post = 330 + offsett
1152 pic11aposl = 326 + offset
1153 pic11apost = 464 + offsett
1154
1155 pic12posl = 490 + offset
1156 pic12post = 330 + offsett
1157 pic12aposl = 486 + offset
1158 pic12apost = 464 + offsett
1159
1160 # set Skinvariables
1161 devicepath = config.plugins.picasa.Device.value
1162
1163 self.focus = Fokus
1164 if self.focus == 1: # MainPic
1165 self.outpath = "mainpic"
1166 if self.focus == 2: # MyPic
1167 self.outpath = "mypic"
1168 if self.focus == 3: # MyPic
1169 self.outpath = "otherpic"
1170 self.newpath = devicepath + self.outpath
1171
1172 self.dict = {
1173 'dev': self.newpath,
1174 'font': font,
1175 'picasa.size': "%i,%i"%(size_w,size_h),
1176 'picasa.pos': "%i,%i"%(pos_w,pos_h),
1177 'green.pos': "%i,5"%(green_pos),
1178 'blue.pos': "%i,5"%(blue_pos),
1179 'green2.pos': "%i,5"%(green2_pos),
1180 'blue2.pos': "%i,5"%(blue2_pos),
1181
1182 'mypic1.pos': "%i,%i"%(pic1posl+8,pic1post+38),
1183 'mypic2.pos': "%i,%i"%(pic2posl+8,pic2post+38),
1184 'mypic3.pos': "%i,%i"%(pic3posl+8,pic3post+38),
1185 'mypic4.pos': "%i,%i"%(pic4posl+8,pic4post+38),
1186 'mypic5.pos': "%i,%i"%(pic5posl+8,pic5post+38),
1187 'mypic6.pos': "%i,%i"%(pic6posl+8,pic6post+38),
1188 'mypic7.pos': "%i,%i"%(pic7posl+8,pic7post+38),
1189 'mypic8.pos': "%i,%i"%(pic8posl+8,pic8post+38),
1190 'mypic9.pos': "%i,%i"%(pic9posl+8,pic9post+38),
1191 'mypic10.pos': "%i,%i"%(pic10posl+8,pic10post+38),
1192 'mypic11.pos': "%i,%i"%(pic11posl+8,pic11post+38),
1193 'mypic12.pos': "%i,%i"%(pic12posl+8,pic12post+38),
1194
1195 'pic1a.pos': "%i,%i"%(pic1aposl,pic1apost),
1196 'pic2a.pos': "%i,%i"%(pic2aposl,pic2apost),
1197 'pic3a.pos': "%i,%i"%(pic3aposl,pic3apost),
1198 'pic4a.pos': "%i,%i"%(pic4aposl,pic4apost),
1199 'pic5a.pos': "%i,%i"%(pic5aposl,pic5apost),
1200 'pic6a.pos': "%i,%i"%(pic6aposl,pic6apost),
1201 'pic7a.pos': "%i,%i"%(pic7aposl,pic7apost),
1202 'pic8a.pos': "%i,%i"%(pic8aposl,pic8apost),
1203 'pic9a.pos': "%i,%i"%(pic9aposl,pic9apost),
1204 'pic10a.pos': "%i,%i"%(pic10aposl,pic10apost),
1205 'pic11a.pos': "%i,%i"%(pic11aposl,pic11apost),
1206 'pic12a.pos': "%i,%i"%(pic12aposl,pic12apost),
1207 }
1208
1209 self.skin = applySkinVars(PicasaMyPic.skin,self.dict)
1210 Screen.__init__(self, session)
1211 self.onShown.append(self.setWindowTitle)
1212
1213 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "ColorActions", "MovieSelectionActions", "MenuActions", "MoviePlayerActions", "InfobarChannelSelection", "ChannelSelectBaseActions", "NumberActions"],
1214 {
1215 "cancel": self.close,
1216 "red": self.close,
1217 "left": self.left2,
1218 "right": self.right2,
1219 "up": self.up2,
1220 "down": self.down2,
1221 "green": self.PicDownload,
1222 "blue": self.SlideShow,
1223 "zapUp": self.nextPage,
1224 "zapDown": self.prevPage,
1225 "ok": self.loadPicture2
1226 }, -2)
1227 # "green": self.MyPic,
1228
1229 self["MyPic1"] = Pixmap()
1230 self["MyPic2"] = Pixmap()
1231 self["MyPic3"] = Pixmap()
1232 self["MyPic4"] = Pixmap()
1233 self["MyPic5"] = Pixmap()
1234 self["MyPic6"] = Pixmap()
1235 self["MyPic7"] = Pixmap()
1236 self["MyPic8"] = Pixmap()
1237 self["MyPic9"] = Pixmap()
1238 self["MyPic10"] = Pixmap()
1239 self["MyPic11"] = Pixmap()
1240 self["MyPic12"] = Pixmap()
1241
1242 self["Pic1a"] = Pixmap()
1243 self["Pic1a"].show()
1244 self["Pic2a"] = Pixmap()
1245 self["Pic2a"].hide()
1246 self["Pic3a"] = Pixmap()
1247 self["Pic3a"].hide()
1248 self["Pic4a"] = Pixmap()
1249 self["Pic4a"].hide()
1250 self["Pic5a"] = Pixmap()
1251 self["Pic5a"].hide()
1252 self["Pic6a"] = Pixmap()
1253 self["Pic6a"].hide()
1254 self["Pic7a"] = Pixmap()
1255 self["Pic7a"].hide()
1256 self["Pic8a"] = Pixmap()
1257 self["Pic8a"].hide()
1258 self["Pic9a"] = Pixmap()
1259 self["Pic9a"].hide()
1260 self["Pic10a"] = Pixmap()
1261 self["Pic10a"].hide()
1262 self["Pic11a"] = Pixmap()
1263 self["Pic11a"].hide()
1264 self["Pic12a"] = Pixmap()
1265 self["Pic12a"].hide()
1266
1267 self["key_red"] = StaticText(_("return"))
1268 self["key_green"] = StaticText(_("Download"))
1269 self["key_yellow"] = StaticText(_("SlideShow"))
1270 self["key_blue"] = StaticText(_("Page=CH +/-"))
1271 self["Seitenzeile"] = StaticText()
1272
1273 self.focus = Fokus
1274 self.pic = 1
1275
1276 print "[Picas MyPic Fokus] " + str(Fokus) + " download " + str(download)
1277 #self.focus = 2 # 1 = MainPic, 2 = MyPic, 3 = otherPic
1278 if self.focus == 1: # MainPic
1279 self.outpath = "mainpic"
1280 if self.focus == 2: # MyPic
1281 self.outpath = "mypic"
1282 if self.focus == 3: # otherPic
1283 self.outpath = "otherpic"
1284
1285 print "[Picasa MyPic] download=" + str(download)
1286 if download == 1 and self.focus == 2:
1287 print "[Picasa] Call self.MyPic"
1288 self.MyPic()
1289 self.onShown.append(self.setWindowTitle)
1290 if download == 1 and self.focus == 3:
1291 print "[Picasa] Call self.OtherPic"
1292 # #self.OtherPic()
1293
1294
1295 self["Seitenzeile"].text = _("Seite:") + str(curpage) + "/" + str(maxpage)
1296
1297#------------------------------------------------------------------------------------------
1298 def MyPic(self):
1299 global selLink
1300 global maxpage
1301 global loadpicnow
1302 global box
1303
1304 devicepath = config.plugins.picasa.Device.value
1305 self.focus = 2
1306 #url = "http://picasaweb.google.com/113655494029816075097/AAF?authkey=Gv1sRgCKifw7rNts75Zg#"
1307 url = selLink
1308 ret = system("checknet picasaweb.google.com")
1309 bild = 0
1310
1311 if box <> "dm8000":
1312 evfd.getInstance().vfd_write_string("downloading... ")
1313
1314 # starten mit der Ansicht "eigene Fotos"
1315 if ret == 0:
1316 try:
1317 h = urllib.urlretrieve(url, "/usr/lib/enigma2/python/Plugins/Extensions/Picasa/private.info")
1318 except:
1319 pass
1320
1321 else:
1322 print "picasaweb.google.com eigene Bilder nicht erreichbar"
1323 session.open(MessageBox, _("picasaweb.google.com is unreachable."), type = MessageBox.TYPE_INFO, timeout = 10)
1324
1325 if self.focus == 1: # MainPic
1326 self.outpath = "mainpic"
1327 fread = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/public.info", "r" )
1328 else: # MyPic
1329 self.outpath = "mypic"
1330 fread = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/private.info", "r" )
1331
1332 if os.path.exists(devicepath + self.outpath) is False:
1333 os.system("mkdir -p " + devicepath + self.outpath)
1334
1335 print "[Picasa MyPic] Seite wurde geladen"
1336 f = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/private.info", "r" )
1337 bild = 0
1338
1339 if box <> "dm8000":
1340 evfd.getInstance().vfd_write_string("search link... ")
1341
1342 for line in f:
1343 zeile = line.lstrip()
1344 # suche Link aus der Seite fuer die Thumbnails
1345 found_link = zeile.find('<div><a href="https://picasaweb.google.com/lh/photo')
1346
1347 if found_link != -1:
1348 found_link = zeile.find('<img src="http://') # <img src="http://lh
1349 LinkThumb = zeile[found_link:-2]
1350
1351 fwrite = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/private.txt", "w" )
1352 fwrite.write(LinkThumb + '\n')
1353 fwrite.close()
1354
1355 # SED ist beim Filtern schneller
1356 os.system("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/private.sh")
1357
1358 self.page = 1
1359 self.totalpath = devicepath + self.outpath + "/" + str(self.page)
1360 CpString = "mkdir -p " + self.totalpath
1361 os.system(CpString)
1362 total = 0
1363 fread = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/private.txt", "r" )
1364 for line in fread:
1365 zeile = line.lstrip()
1366 found_link = zeile.find('<img src="')
1367 found_jpg = zeile.find('s128')
1368
1369 if found_link != -1 and found_jpg != -1:
1370 bild = bild + 1
1371 total = total + 1
1372 if box <> "dm8000":
1373 evfd.getInstance().vfd_write_string("Picture " + str(total))
1374
1375 if bild >= 13: # naechste Seite anlegen
1376 self.page = self.page + 1
1377 bild = 1
1378 self.totalpath = devicepath + self.outpath + "/" + str(self.page)
1379 CpString = "mkdir -p " + self.totalpath
1380 os.system(CpString)
1381
1382 LinkThumb = zeile[found_link + 10:-2]
1383 print "[Picasa]" + LinkThumb
1384
1385 fwrite = open(devicepath + self.outpath + "/" + str(self.page) + "/pic_" + str(bild) + ".lnk", "w" )
1386 fwrite.write(LinkThumb + '\n')
1387 fwrite.close()
1388
1389 if loadpicnow == 0:
1390 self.LoadMainPic2(LinkThumb,bild)
1391
1392 maxpage = self.page
1393 #self.maxpage = self.page
1394 print "[Picasa] maxpage in der loop=" + str(maxpage)
1395
1396 # Dummy Bilder ins View Verzeichnis kopieren wenn nicht 12 erreicht werden
1397 CpString = "cp -f /usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/* " + devicepath + self.outpath
1398 os.system(CpString)
1399
1400 # die ersten 12 Bilder ins View Verzeichnis kopieren
1401 CpString = "cp -f " + devicepath + self.outpath + "/1/* " + devicepath + self.outpath
1402 os.system(CpString)
1403
1404
1405#------------------------------------------------------------------------------------------
1406 def setWindowTitle(self):
1407 global selLink
1408 print str(self.focus) + " " + selLink
1409
1410# es gibt diese 2 Varianten
1411# http://picasaweb.google.com/data/feed/base/all?alt=rss&kind=photo&access=public&tag=air&filter=1&hl=de
1412# http://picasaweb.google.com/data/feed/base/all?alt=rss&kind=photo&access=public&filter=1&q=corvette&hl=de
1413
1414 # den Titel fuer die Ueberschrift herausfiltern
1415 if self.focus == 3:
1416 titel = findall(r'tag=(.*?)\&filter',selLink)
1417 titel = str(titel)
1418 titel = titel.replace("['","").replace("']","")
1419 if titel == "" or titel == "[]":
1420 titel = findall(r'filter=1\&q=(.*?)\&hl',selLink)
1421 titel = str(titel)
1422 titel = titel.replace("['","").replace("']","")
1423
1424 self.setTitle(_("Picasa Webalbum: ") + titel)
1425 else:
1426 titel = findall(r'picasaweb.google.com/.*?/(.*?)\?authkey',selLink)
1427 titel = str(titel)
1428 titel = titel.replace("['","").replace("']","")
1429 self.setTitle(_("Picasa eigene Fotos: ") + titel)
1430
1431#------------------------------------------------------------------------------------------
1432 def PicDownload(self):
1433 global box
1434 devicepath = config.plugins.picasa.Device.value
1435 path = devicepath + "Slideshow/"
1436 #config.plugins.mc_pp.lastDir.save
1437 if os.path.exists(devicepath + "Slideshow") is False:
1438 os.system("mkdir -p " + devicepath + "Slideshow")
1439 else:
1440 os.system("rm " + path + "*")
1441
1442 # tausche die Aufloesung und erhoehe sie
1443 if self.focus == 2: # myPic
1444 self.outpath = "mypic"
1445 if self.focus == 3: # OtherPic
1446 self.outpath = "otherpic"
1447
1448 self.pixel = config.plugins.picasa.max_picpixel.value
1449
1450 picmax = 12
1451 picdef = config.plugins.picasa.max_otherpic.value
1452 x = 0
1453 picnr = 0
1454 seite = 0
1455 seitenr = 0
1456 prenr = "a"
1457 maxseite = config.plugins.picasa.max_otherpic.value
1458
1459 # im Ram auf 1 Seite begrenzen
1460 if devicepath == "/usr/lib/enigma2/python/Plugins/Extensions/Picasa/":
1461 maxseite = 1
1462
1463 while x < maxseite:
1464 #while x < picdef:
1465 x = x + 1
1466 if os.path.exists(devicepath + self.outpath + "/" + str(x)) is True:
1467 picnr = 0
1468 seite = seite + 1
1469
1470 while picnr < picmax:
1471 picnr = picnr + 1
1472 seitenr = seitenr + 1
1473 if box <> "dm8000":
1474 evfd.getInstance().vfd_write_string("Picture " + str(picnr))
1475
1476 sourcepath = devicepath + self.outpath + "/" + str(x) + "/pic_" + str(picnr) + ".lnk"
1477 if fileExists(sourcepath):
1478 CpString = "sed -e 's:s128:s" + self.pixel +":g' -i " + sourcepath
1479 os.system(CpString)
1480 file = open(sourcepath, "r")
1481 BigUrl = file.readline().strip()
1482 print "[Picasa] BigUrl" + BigUrl
1483 file.close()
1484 if seitenr == 10:
1485 prenr = "b"
1486 if seitenr == 20:
1487 prenr = "c"
1488 if seitenr == 10:
1489 prenr = "d"
1490 if seitenr == 30:
1491 prenr = "e"
1492 if seitenr == 40:
1493 prenr = "f"
1494 if seitenr == 50:
1495 prenr = "g"
1496 if seitenr == 60:
1497 prenr = "h"
1498 if seitenr == 70:
1499 prenr = "i"
1500 h = urllib.urlretrieve(BigUrl, devicepath + "Slideshow/pic_" + prenr + str(seitenr) + ".jpg")
1501
1502 #self.filelist = FileList(path, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)")
1503 #self["filelist"] = self.filelist
1504 #self.session.open(PicShow, self.filelist.getFileList(), 0, path, True)
1505
1506#------------------------------------------------------------------------------------------
1507 def SlideShow(self):
1508 sourcepath = devicepath + self.outpath + "/1/pic_1.lnk"
1509 print "[Picasa] SlideShow " + sourcepath
1510 if fileExists(sourcepath):
1511 self.PicDownload()
1512 self.session.open(View_Slideshow, 0, True)
1513
1514#------------------------------------------------------------------------------------------
1515 def loadPicture2(self):
1516 devicepath = config.plugins.picasa.Device.value
1517 path = devicepath + "mainpicBig/"
1518 if os.path.exists(devicepath + "mainpicBig") is False:
1519 os.system("mkdir -p " + devicepath + "mainpicBig")
1520 else:
1521 os.system("rm " + path + "*")
1522
1523 # tausche die Aufloesung und erhoehe sie
1524 if self.focus == 2: # myPic
1525 self.outpath = "mypic"
1526 if self.focus == 3: # OtherPic
1527 self.outpath = "otherpic"
1528
1529 self.pixel = config.plugins.picasa.max_picpixel.value
1530 CpString = "sed -e 's:s128:s" + self.pixel +":g' -i " + devicepath + self.outpath + "/pic_" + str(self.pic) + ".lnk"
1531 os.system(CpString)
1532
1533
1534 if fileExists(devicepath + self.outpath + "/pic_" + str(self.pic) + ".lnk"):
1535 file = open(devicepath + self.outpath + "/pic_" + str(self.pic) + ".lnk", "r")
1536 BigUrl = file.readline().strip()
1537 print "[Picasa] BigUrl" + BigUrl
1538 file.close()
1539
1540 self.LoadMainPicBig2(BigUrl, self.pic)
1541 filelist = FileList(path, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)")
1542 filelist = devicepath + "mainpicBig/pic_" + str(self.pic) + ".jpg"
1543 self.session.open(PicView, filelist, 0, path, False)
1544
1545#------------------------------------------------------------------------------------------
1546 def down2(self):
1547 if self.pic <= 8:
1548 self.pic = self.pic + 4
1549 self.setPicture2(self.pic)
1550
1551#------------------------------------------------------------------------------------------
1552 def up2(self):
1553 if self.pic >= 5:
1554 self.pic = self.pic - 4
1555 self.setPicture2(self.pic)
1556
1557#------------------------------------------------------------------------------------------
1558 def left2(self):
1559 if self.pic > 1:
1560 self.pic = self.pic - 1
1561 self.setPicture2(self.pic)
1562
1563#------------------------------------------------------------------------------------------
1564 def right2(self):
1565 if self.pic < 12:
1566 self.pic = self.pic + 1
1567 self.setPicture2(self.pic)
1568
1569#------------------------------------------------------------------------------------------
1570 def prevPage(self):
1571 global page
1572 print "[Picasa] nextPage"
1573 page = "next"
1574 self.close()
1575
1576#------------------------------------------------------------------------------------------
1577 def nextPage(self):
1578 global page
1579 print "[Picasa] prevPage"
1580 page = "prev"
1581 self.close()
1582
1583#------------------------------------------------------------------------------------------
1584 def setPicture2(self,counter):
1585 self["Pic1a"].hide()
1586 self["Pic2a"].hide()
1587 self["Pic3a"].hide()
1588 self["Pic4a"].hide()
1589 self["Pic5a"].hide()
1590 self["Pic6a"].hide()
1591 self["Pic7a"].hide()
1592 self["Pic8a"].hide()
1593 self["Pic9a"].hide()
1594 self["Pic10a"].hide()
1595 self["Pic11a"].hide()
1596 self["Pic12a"].hide()
1597
1598 if counter == 1:
1599 self["Pic1a"].show()
1600 if counter == 2:
1601 self["Pic2a"].show()
1602 if counter == 3:
1603 self["Pic3a"].show()
1604 if counter == 4:
1605 self["Pic4a"].show()
1606 if counter == 5:
1607 self["Pic5a"].show()
1608 if counter == 6:
1609 self["Pic6a"].show()
1610 if counter == 7:
1611 self["Pic7a"].show()
1612 if counter == 8:
1613 self["Pic8a"].show()
1614 if counter == 9:
1615 self["Pic9a"].show()
1616 if counter == 10:
1617 self["Pic10a"].show()
1618 if counter == 11:
1619 self["Pic11a"].show()
1620 if counter == 12:
1621 self["Pic12a"].show()
1622
1623#------------------------------------------------------------------------------------------
1624 def LoadMainPic2(self,url,counter):
1625 # lade die Vorschaubilder und lege sie ab
1626 devicepath = config.plugins.picasa.Device.value
1627 self.previewPath =devicepath + self.outpath + "/" + str(self.page) + "/pic_" + str(counter) + ".jpg"
1628 h = urllib.urlretrieve(url, self.previewPath)
1629
1630#------------------------------------------------------------------------------------------
1631 def LoadMainPicBig2(self,url,counter):
1632 # lade die Vorschaubilder und lege sie ab
1633 h = urllib.urlretrieve(url, devicepath + "mainpicBig/pic_" + str(counter) + ".jpg")
1634
1635#------------------------------------------------------------------------------------------
1636#-------------------------------- Picasa Settings -----------------------------------------
1637#------------------------------------------------------------------------------------------
1638class PicSetup(Screen):
1639 skin = """<screen position="center,center" size="480,360" title="Picasa Settings" backgroundColor="#000000" >
1640 <widget name="liste" position="5,5" size="470,350" scrollbarMode="showOnDemand" />
1641 <eLabel backgroundColor="red" position="28,350" size="140,3" zPosition="2"/>
1642 <eLabel backgroundColor="green" position="228,350" size="140,3" zPosition="2"/>
1643 <widget name="key_red" position="28,318" zPosition="3" size="140,40" font="Regular;19" valign="center" halign="center" transparent="1" />
1644 <widget name="key_green" position="228,318" zPosition="3" size="140,40" font="Regular;19" valign="center" halign="center" transparent="1" />
1645 </screen>"""
1646
1647 def __init__(self, session):
1648 self.skin = PicSetup.skin
1649 Screen.__init__(self, session)
1650 self["key_red"] = Button(_("Back"))
1651 self["key_green"] = Button(_("Save"))
1652 self["actions"] = NumberActionMap(["SetupActions", "ColorActions"],
1653 {
1654 "ok": self.save,
1655 "green": self.save,
1656 "cancel": self.close,
1657 "red": self.close,
1658 "left": self.keyLeft,
1659 "right": self.keyRight,
1660 "0": self.keyNumber,
1661 "1": self.keyNumber,
1662 "2": self.keyNumber,
1663 "3": self.keyNumber,
1664 "4": self.keyNumber,
1665 "5": self.keyNumber,
1666 "6": self.keyNumber,
1667 "7": self.keyNumber,
1668 "8": self.keyNumber,
1669 "9": self.keyNumber
1670 }, -3)
1671 self.list = []
1672 self["liste"] = ConfigList(self.list)
1673
1674 self.list.append(getConfigListEntry(_("Picture Y moving"), config.plugins.picasa.max_offsety))
1675 self.list.append(getConfigListEntry(_("max. Picture Sites"), config.plugins.picasa.max_otherpic))
1676 self.list.append(getConfigListEntry(_("Picture Size"), config.plugins.picasa.max_picpixel))
1677 self.list.append(getConfigListEntry(_("delete cached Pictures"), config.plugins.picasa.remove))
1678 self.list.append(getConfigListEntry(_("Picture Cache"), config.plugins.picasa.Device))
1679 self.list.append(getConfigListEntry(_("Scaling Mode"), config.plugins.picasa.resize))
1680 self.list.append(getConfigListEntry(_("Frame size in full view"), config.plugins.picasa.framesize))
1681 self.list.append(getConfigListEntry(_("backgroundcolor"), config.plugins.picasa.bgcolor))
1682 self.list.append(getConfigListEntry(_("Textcolor"), config.plugins.picasa.textcolor))
1683 self.list.append(getConfigListEntry(_("SlideTime"), config.plugins.picasa.slidetime))
1684 self.list.append(getConfigListEntry(_("Show Infoline"), config.plugins.picasa.infoline))
1685 self.list.append(getConfigListEntry(_("slide picture in loop"), config.plugins.picasa.loop))
1686
1687 def save(self):
1688 for x in self["liste"].list:
1689 x[1].save()
1690 config.save()
1691 self.close()
1692
1693 def keyLeft(self):
1694 self["liste"].handleKey(KEY_LEFT)
1695 def keyRight(self):
1696 self["liste"].handleKey(KEY_RIGHT)
1697 def keyNumber(self, number):
1698 self["liste"].handleKey(KEY_0 + number)
1699
1700
1701#------------------------------------------------------------------------------------------
1702#-------------------------------- Webalbum selektieren ------------------------------------
1703#------------------------------------------------------------------------------------------
1704class SelectGroup(Screen):
1705 skin = """<screen position="center,center" size="440,350" title="Group Selection" >
1706 <widget name="filelist" transparent="1" position="50,35" zPosition="2" size="340,260" scrollbarMode="showOnDemand" enableWrapAround="1" />
1707 <widget name="currentfolder" zPosition="5" transparent="1" halign="left" position="15,15" size="590,20" font="Regular;16" foregroundColor="#f0f0f0" />
1708 <eLabel backgroundColor="red" position="3,340" size="115,3" zPosition="5"/>
1709 <eLabel backgroundColor="green" position="155,340" size="115,3" zPosition="5"/>
1710 <eLabel backgroundColor="yellow" position="307,340" size="115,3" zPosition="5"/>
1711 <widget name="key_red" position="3,306" zPosition="1" size="115,40" font="Regular;20" halign="center" valign="center" transparent="1" />
1712 <widget name="key_green" position="155,306" zPosition="1" size="115,40" font="Regular;20" halign="center" valign="center" transparent="1" />
1713 <widget name="key_yellow" position="307,306" zPosition="1" size="115,40" font="Regular;20" halign="center" valign="center" transparent="1" />
1714 </screen>"""
1715
1716 def __init__(self, session, fokus):
1717 self.session = session
1718
1719 Screen.__init__(self, session)
1720 self.skin = SelectGroup.skin
1721 self.onShown.append(self.setWindowTitle)
1722
1723 self["currentfolder"] = Label("")
1724 self["key_green"] = Label(_("Select"))
1725
1726 if fokus == 3:
1727 self["key_red"] = Label(_("Search"))
1728 else:
1729 self["key_red"] = Label(_(" "))
1730
1731 self["key_yellow"] = Label(_("Delete"))
1732 self.curfavfolder = -1
1733
1734 self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "ColorActions"],
1735 {
1736 "cancel": self.Exit,
1737 "ok": self.KeyOk,
1738 "left": self.leftUp,
1739 "right": self.rightDown,
1740 "up": self.up,
1741 "down": self.down,
1742 "green": self.KeyOk,
1743 "red": self.virtualKB,
1744 "yellow": self.DelFile,
1745 }, -4)
1746
1747
1748 if fokus == 2:
1749 self.link = "Link"
1750 if fokus == 3:
1751 self.link = "Linkother"
1752
1753 print "[Picasa Fokus] " + str(fokus)
1754
1755 currDir = "/usr/lib/enigma2/python/Plugins/Extensions/Picasa/" + self.link
1756 if not os.path.exists(currDir):
1757 os.system("mkdir -p /usr/lib/enigma2/python/Plugins/Extensions/Picasa/" + self.link)
1758
1759 #self["currentfolder"].setText(str(currDir))
1760 self.filelist = FileList(currDir, showDirectories = False, matchingPattern = "^.*", useServiceRef = False)
1761 self["filelist"] = self.filelist
1762
1763 def setWindowTitle(self):
1764 self.setTitle(_("Auswahl - Webalbum"))
1765
1766 def up(self):
1767 self["filelist"].up()
1768
1769 def down(self):
1770 self["filelist"].down()
1771
1772 def leftUp(self):
1773 self["filelist"].pageUp()
1774
1775 def rightDown(self):
1776 self["filelist"].pageDown()
1777
1778 def DelFile(self):
1779 global selLink
1780 filename = self["filelist"].getFilename()
1781 os.system("rm -r /usr/lib/enigma2/python/Plugins/Extensions/Picasa/" + self.link + "/" + filename)
1782 self.filelist.refresh
1783
1784 def KeyOk(self):
1785 global selLink
1786 filename = self["filelist"].getFilename()
1787 if self.link == "Link": # nur bei eigenen Bildern speichern
1788 fwrite = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/curpic", "w" )
1789 fwrite.write(filename)
1790 fwrite.close()
1791
1792 file = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/" + self.link + "/" + filename, "r")
1793 selLink = file.readline().strip()
1794 print selLink
1795 file.close()
1796 self.close()
1797
1798 def Exit(self):
1799 global selLink
1800 selLink = "stop"
1801 self.close()
1802
1803 def virtualKB(self):
1804 if self.link == "Linkother": # nur bei oeffentliche Pic suche erlauben
1805 self.search = ""
1806 self.session.openWithCallback(lambda x : self.VirtualKeyBoardCallback(x, ''), VirtualKeyBoard, title = (_("Thema of Foto search")), text = self.search)
1807
1808
1809 def VirtualKeyBoardCallback(self, callback = None, entry = None):
1810 global selLink
1811 print "[Virtual KB] callback", callback
1812
1813 if callback is not None and len(callback):
1814 print "[Picasa] virtual callback",str(callback)
1815 selLink = "http://picasaweb.google.com/data/feed/base/all?alt=rss&kind=photo&access=public&tag="+ callback + "&filter=1&hl=de"
1816 self.fname = callback
1817
1818 message = "%s %s" % (self.fname, _("\n\nSoll diese Suche als Link gespeichert werden?"))
1819 self.session.openWithCallback(self.save_now, MessageBox, message, MessageBox.TYPE_YESNO)
1820 self.close()
1821
1822 def save_now(self, answer):
1823 global selLink
1824 if answer == True:
1825 file = open("/usr/lib/enigma2/python/Plugins/Extensions/Picasa/Linkother/" + self.fname, "w")
1826 file.write(selLink)
1827 file.close()
1828
1829
1830
1831#------------------------------------------------------------------------------------------
1832#-------------------------- Bildbetrachter der Grossbilder --------------------------------
1833#------------------------------------------------------------------------------------------
1834class PicView(Screen):
1835 def __init__(self, session, filelist, index, path, startslide):
1836 self.session = session
1837 self.bgcolor = config.plugins.picasa.bgcolor.value
1838 space = config.plugins.picasa.framesize.value
1839 size_w = getDesktop(0).size().width()
1840 size_h = getDesktop(0).size().height()
1841
1842 #self.skindir = config.plugins.mc_globalsettings.currentskin.path.value.split('/')[0]
1843 self.skindir = "/tmp"
1844 self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" > \
1845 <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\""+ self.bgcolor +"\" /><widget name=\"pic\" position=\"" + str(space) + "," + str(space) + "\" size=\"" + str(size_w-(space*2)) + "," + str(size_h-(space*2)) + "\" zPosition=\"1\" alphatest=\"on\" /></screen>"
1846
1847 Screen.__init__(self, session)
1848 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions", "MenuActions", "SetupActions"],
1849 {
1850 "cancel": self.Exit,
1851 }, -1)
1852
1853 self["pic"] = Pixmap()
1854 self.filelist = filelist
1855 self.old_index = 0
1856 self.lastindex = index
1857 self.currPic = []
1858 self.shownow = True
1859 self.dirlistcount = 0
1860 self.index = 0
1861 self.picload = ePicLoad()
1862 self.picload.PictureData.get().append(self.finish_decode)
1863 self.onLayoutFinish.append(self.setPicloadConf)
1864 self.startslide = startslide
1865
1866 def setPicloadConf(self):
1867 sc = getScale()
1868 self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), sc[0], sc[1], 0, int(config.plugins.picasa.resize.value), self.bgcolor])
1869 self.start_decode()
1870
1871 def ShowPicture(self):
1872 if self.shownow and len(self.currPic):
1873 self.shownow = False
1874 self["pic"].instance.setPixmap(self.currPic[0].__deref__())
1875
1876 def finish_decode(self, picInfo=""):
1877 ptr = self.picload.getData()
1878 if ptr != None:
1879 self.currPic = []
1880 self.currPic.append(ptr)
1881 self.ShowPicture()
1882
1883 def start_decode(self):
1884 self.picload.startDecode(self.filelist)
1885
1886 def Exit(self):
1887 del self.picload
1888 self.close(self.lastindex + self.dirlistcount)
1889
1890#------------------------------------------------------------------------------------------
1891class View_Slideshow(Screen, InfoBarAspectSelection, InfoBarResolutionSelection):
1892 def __init__(self, session, pindex, startslide):
1893
1894 print "SlideShow is running ......."
1895 self.textcolor = config.plugins.picasa.textcolor.value
1896 self.bgcolor = config.plugins.picasa.bgcolor.value
1897 space = config.plugins.picasa.framesize.value
1898 size_w = getDesktop(0).size().width()
1899 size_h = getDesktop(0).size().height()
1900
1901 self.skindir = "/tmp"
1902 self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
1903 <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\""+ self.bgcolor +"\" /><widget name=\"pic\" position=\"" + str(space) + "," + str(space) + "\" size=\"" + str(size_w-(space*2)) + "," + str(size_h-(space*2)) + "\" zPosition=\"1\" alphatest=\"on\" /> \
1904 <widget name=\"point\" position=\""+ str(space+5) + "," + str(space+10) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"/usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/record.png\" alphatest=\"on\" /> \
1905 <widget name=\"play_icon\" position=\""+ str(space+25) + "," + str(space+10) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"/usr/lib/enigma2/python/Plugins/Extensions/Picasa/default/ico_mp_play.png\" alphatest=\"on\" /> \
1906 <widget name=\"file\" position=\""+ str(space+45) + "," + str(space+8) + "\" size=\""+ str(size_w-(space*2)-50) + ",25\" font=\"Regular;20\" halign=\"left\" foregroundColor=\"" + self.textcolor + "\" zPosition=\"2\" noWrap=\"1\" transparent=\"1\" /></screen>"
1907 Screen.__init__(self, session)
1908
1909 InfoBarAspectSelection.__init__(self)
1910 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
1911 {
1912 "cancel": self.Exit,
1913 "yellow": self.PlayPause,
1914 "blue": self.sleepTimer,
1915 "left": self.prevPic,
1916 "right": self.nextPic,
1917 }, -1)
1918 self["point"] = Pixmap()
1919 self["pic"] = Pixmap()
1920 self["play_icon"] = Pixmap()
1921 self["file"] = Label(_("please wait, loading picture..."))
1922 self.old_index = 0
1923 self.picfilelist = []
1924 self.lastindex = pindex
1925 self.currPic = []
1926 self.shownow = True
1927 self.dirlistcount = 0
1928
1929 devicepath = config.plugins.picasa.Device.value
1930 currDir = devicepath + "Slideshow/"
1931 self.filelist = FileList(currDir, showDirectories = False, matchingPattern = "^.*\.(jpg)", useServiceRef = False)
1932
1933 for x in self.filelist.getFileList():
1934 if x[0][1] == False:
1935 self.picfilelist.append(currDir + x[0][0])
1936 else:
1937 self.dirlistcount += 1
1938
1939 self.maxentry = len(self.picfilelist)-1
1940 self.pindex = pindex - self.dirlistcount
1941 if self.pindex < 0:
1942 self.pindex = 0
1943 self.picload = ePicLoad()
1944 self.picload.PictureData.get().append(self.finish_decode)
1945 self.slideTimer = eTimer()
1946 self.slideTimer.callback.append(self.slidePic)
1947 if self.maxentry >= 0:
1948 self.onLayoutFinish.append(self.setPicloadConf)
1949 if startslide == True:
1950 self.PlayPause();
1951
1952 def setPicloadConf(self):
1953 sc = getScale()
1954 self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), sc[0], sc[1], 0, int(config.plugins.picasa.resize.value), self.bgcolor])
1955 self["play_icon"].hide()
1956 if config.plugins.picasa.infoline.value == False:
1957 self["file"].hide()
1958 self.start_decode()
1959
1960 def ShowPicture(self):
1961 if self.shownow and len(self.currPic):
1962 self.shownow = False
1963 self["file"].setText(self.currPic[0])
1964 self.lastindex = self.currPic[1]
1965 self["pic"].instance.setPixmap(self.currPic[2].__deref__())
1966 self.currPic = []
1967 self.next()
1968 self.start_decode()
1969
1970 def finish_decode(self, picInfo=""):
1971 self["point"].hide()
1972 ptr = self.picload.getData()
1973 if ptr != None:
1974 text = ""
1975 try:
1976 text = picInfo.split('\n',1)
1977 text = "(" + str(self.pindex+1) + "/" + str(self.maxentry+1) + ") " + text[0].split('/')[-1]
1978 except:
1979 pass
1980 self.currPic = []
1981 self.currPic.append(text)
1982 self.currPic.append(self.pindex)
1983 self.currPic.append(ptr)
1984 self.ShowPicture()
1985
1986 def start_decode(self):
1987 self.picload.startDecode(self.picfilelist[self.pindex])
1988 self["point"].show()
1989
1990 def next(self):
1991 self.pindex += 1
1992 if self.pindex > self.maxentry:
1993 self.pindex = 0
1994
1995 def prev(self):
1996 self.pindex -= 1
1997 if self.pindex < 0:
1998 self.pindex = self.maxentry
1999
2000 def slidePic(self):
2001 print "[Picasa] slide to next Picture index=" + str(self.lastindex)
2002 if config.plugins.picasa.loop.value==False and self.lastindex == self.maxentry:
2003 self.PlayPause()
2004 self.shownow = True
2005 self.ShowPicture()
2006
2007 def PlayPause(self):
2008 if self.slideTimer.isActive():
2009 self.slideTimer.stop()
2010 self["play_icon"].hide()
2011 else:
2012 self.slideTimer.start(config.plugins.picasa.slidetime.value*1000)
2013 self["play_icon"].show()
2014 self.nextPic()
2015
2016 def prevPic(self):
2017 self.currPic = []
2018 self.pindex = self.lastindex
2019 self.prev()
2020 self.start_decode()
2021 self.shownow = True
2022
2023 def nextPic(self):
2024 self.shownow = True
2025 self.ShowPicture()
2026
2027 def Exit(self):
2028 del self.picload
2029 self.close(self.lastindex + self.dirlistcount)
2030
2031 def sleepTimer(self):
2032 from Screens.SleepTimerEdit import SleepTimerEdit
2033 self.session.open(SleepTimerEdit)
2034
2035
2036#------------------------------------------------------------------------------------------
2037#-----------------------Haupt Programm ----------------------------------------------------
2038#------------------------------------------------------------------------------------------
2039def main(session, **kwargs):
2040
2041 url = "http://picasaweb.google.com/lh/explore#"
2042 ret = system("checknet picasaweb.google.com")
2043 bild = 0
2044
2045 # starten mit der Ansicht "empfohlene Fotos"
2046 if ret == 0:
2047 h = urllib.urlretrieve(url, "/usr/lib/enigma2/python/Plugins/Extensions/Picasa/public.info")
2048 session.open(PicasaMain)
2049 else:
2050 print "picasaweb.google.com nicht erreichbar"
2051 session.open(MessageBox, _("picasaweb.google.com is unreachable."), type = MessageBox.TYPE_INFO, timeout = 10)
2052
2053#------------------------------------------------------------------------------------------
2054def Plugins(**kwargs):
2055 return [
2056 PluginDescriptor(name = "Picasa", description = "Bilder von Picasa ansehen, auch eigene", icon="Picasa.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc = main),
2057 PluginDescriptor(name = "Picasa", description = "Bilder von Picasa ansehen, auch eigene", icon="Picasa.png", where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main)]
Note: See TracBrowser for help on using the repository browser.