forked from phil65/script.extendedinfo
/
default.py
900 lines (877 loc) · 49.7 KB
/
default.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
import sys
import os, time, datetime
import xbmc, xbmcgui, xbmcaddon, xbmcplugin
from Utils import log, prettyprint
if sys.version_info < (2, 7):
import simplejson
else:
import json as simplejson
__addon__ = xbmcaddon.Addon()
__addonid__ = __addon__.getAddonInfo('id')
__addonversion__ = __addon__.getAddonInfo('version')
__language__ = __addon__.getLocalizedString
TrackTitle = None
AdditionalParams = []
Window = 10000
extrathumb_limit = 4
extrafanart_limit = 10
Addon_Data_Path = os.path.join( xbmc.translatePath("special://profile/addon_data/%s" % __addonid__ ).decode("utf-8") )
Skin_Data_Path = os.path.join( xbmc.translatePath("special://profile/addon_data/%s" % xbmc.getSkinDir() ).decode("utf-8") )
def GetDatabaseID(type,dbid):
if type=="movie":
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieDetails", "params": {"properties": ["imdbnumber","title", "year"], "movieid":%s }, "id": 1}' % dbid)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
if "moviedetails" in json_response["result"]:
return json_response['result']['moviedetails']['imdbnumber']
else:
return []
elif type == "tvshow":
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetTVShowDetails", "params": {"properties": ["imdbnumber","title", "year"], "tvshowid":%s }, "id": 1}' % dbid)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_response = simplejson.loads(json_query)
if "tvshowdetails" in json_response["result"]:
return json_response['result']['tvshowdetails']['imdbnumber']
else:
return []
def passHomeDataToSkin(data, debug = True):
wnd = xbmcgui.Window(Window)
if data != None:
for (key,value) in data.iteritems():
wnd.setProperty('%s' % (str(key)), unicode(value))
if debug:
log('%s' % (str(key)) + unicode(value))
def passDataToSkin(name, data, prefix="",debug = False):
wnd = xbmcgui.Window(Window)
if data != None:
log( "%s%s.Count = %s" % (prefix, name, str(len(data)) ) )
for (count, result) in enumerate(data):
if debug:
log( "%s%s.%i = %s" % (prefix, name, count + 1, str(result) ) )
for (key,value) in result.iteritems():
wnd.setProperty('%s%s.%i.%s' % (prefix, name, count + 1, str(key)), unicode(value))
if debug:
log('%s%s.%i.%s --> ' % (prefix, name, count + 1, str(key)) + unicode(value))
wnd.setProperty('%s%s.Count' % (prefix, name), str(len(data)))
else:
wnd.setProperty('%s%s.Count' % (prefix, name), '0')
log( "%s%s.Count = None" % (prefix, name ) )
class Main:
def __init__( self ):
log("version %s started" % __addonversion__ )
xbmc.executebuiltin('SetProperty(extendedinfo_running,True,home)')
self._init_vars()
self._parse_argv()
# run in backend if parameter was set
if self.infos:
self._StartInfoActions()
elif self.exportsettings:
from Utils import export_skinsettings
export_skinsettings()
elif self.importsettings:
from Utils import import_skinsettings
import_skinsettings()
elif self.importextrathumb:
from Utils import AddArtToLibrary
AddArtToLibrary("extrathumb","Movie","extrathumbs",extrathumb_limit,True)
elif self.importextrafanart:
from Utils import AddArtToLibrary
AddArtToLibrary("extrafanart","Movie","extrafanart",extrafanart_limit,True)
# elif self.importextrathumbtv:
# AddArtToLibrary("extrathumb","TVShow","extrathumbs")
elif self.importextrafanarttv:
from Utils import AddArtToLibrary
AddArtToLibrary("extrafanart","TVShow","extrafanart",extrafanart_limit,True)
elif self.importallartwork:
from Utils import AddArtToLibrary
AddArtToLibrary("extrathumb","Movie","extrathumbs",extrathumb_limit,True)
AddArtToLibrary("extrafanart","Movie","extrafanart",extrafanart_limit,True)
AddArtToLibrary("extrafanart","TVShow","extrafanart",extrafanart_limit,True)
elif self.backend and xbmc.getCondVisibility("IsEmpty(Window(home).Property(extendedinfo_backend_running))"):
xbmc.executebuiltin('SetProperty(extendedinfo_backend_running,True,home)')
self.run_backend()
# only set new properties if artistid is not smaller than 0, e.g. -1
elif self.artistid and self.artistid > -1:
self._set_details(self.artistid)
# else clear old properties
elif not len(sys.argv) >1:
self._selection_dialog()
xbmc.executebuiltin('ClearProperty(extendedinfo_running,home)')
def _StartInfoActions(self):
if not self.silent:
xbmc.executebuiltin( "ActivateWindow(busydialog)" )
for info in self.infos:
if info == 'json':
from MiscScraper import GetYoutubeVideos
videos = GetYoutubeVideos(self.feed,self.prop_prefix)
passDataToSkin('RSS', videos, self.prop_prefix)
elif info == 'similarlocal' and self.dbid:
passDataToSkin('SimilarLocalMovies', None , self.prop_prefix)
from Utils import GetSimilarFromOwnLibrary
passDataToSkin('SimilarLocalMovies', GetSimilarFromOwnLibrary(self.dbid) , self.prop_prefix)
elif info == 'xkcd':
log("startin GetXKCDInfo")
from MiscScraper import GetXKCDInfo
passDataToSkin('XKCD', GetXKCDInfo(), self.prop_prefix)
elif info == 'flickr':
from MiscScraper import GetFlickrImages
log("startin flickr")
passDataToSkin('Flickr', GetFlickrImages(), self.prop_prefix)
elif info == 'discography':
passDataToSkin('Discography', None, self.prop_prefix)
log("startin gettopalbums")
from OnlineMusicInfo import GetArtistTopAlbums
passDataToSkin('Discography', GetArtistTopAlbums(self.Artist_mbid), self.prop_prefix)
elif info == 'artistdetails':
passDataToSkin('Discography', None, self.prop_prefix)
passDataToSkin('MusicVideos', None, self.prop_prefix)
log("startin ArtistDetails")
from TheAudioDB import GetDiscography, GetArtistDetails, GetMostLovedTracks, GetMusicVideos
ArtistDetails = GetArtistDetails(self.ArtistName)
MusicVideos = GetMusicVideos(ArtistDetails["audiodbid"])
# GetAudioDBData("search.php?s=Blur")
GetMostLovedTracks(self.ArtistName)
passDataToSkin('MusicVideos', MusicVideos, self.prop_prefix)
# from TheAudioDB import GetArtistTopAlbums
passDataToSkin('Discography', GetDiscography(self.ArtistName), self.prop_prefix)
passHomeDataToSkin(ArtistDetails)
elif info == 'albuminfo':
passHomeDataToSkin(None)
log("startin ArtistDetails")
from TheAudioDB import GetAlbumDetails, GetTrackDetails
if self.id:
AlbumDetails = GetAlbumDetails(self.id)
Trackinfo = GetTrackDetails(self.id)
prettyprint(AlbumDetails)
passHomeDataToSkin(AlbumDetails)
passDataToSkin('Trackinfo', Trackinfo, self.prop_prefix)
elif info == 'shouts':
log("startin shouts")
passDataToSkin('Shout', None, self.prop_prefix)
from OnlineMusicInfo import GetShouts
passDataToSkin('Shout', GetShouts(self.ArtistName,self.AlbumName), self.prop_prefix,True)
elif info == 'studio':
passDataToSkin('StudioInfo', None, self.prop_prefix)
if self.studio:
log("startin companyinfo")
from TheMovieDB import SearchforCompany, GetCompanyInfo
CompanyId = SearchforCompany(self.studio)
passDataToSkin('StudioInfo', GetCompanyInfo(CompanyId), self.prop_prefix)
elif info == 'set':
passDataToSkin('MovieSetItems', None, self.prop_prefix)
if self.dbid and not "show" in str(self.type):
from TheMovieDB import SearchForSet
from Utils import GetMovieSetName
name = GetMovieSetName(self.dbid)
if name:
log(name)
self.setid = SearchForSet(name)
log("yyyy")
log(self.setid)
if self.setid:
log("startin SetInfo")
from TheMovieDB import GetSetMovies
SetData = GetSetMovies(self.setid)
if SetData:
passDataToSkin('MovieSetItems', SetData, self.prop_prefix)
elif info == 'topartists':
passDataToSkin('TopArtists', None, self.prop_prefix)
log("startin gettopartists")
from OnlineMusicInfo import GetTopArtists
passDataToSkin('TopArtists', GetTopArtists(), self.prop_prefix)
elif info == 'cyanide':
log("startin GetCandHInfo")
from MiscScraper import GetCandHInfo
passDataToSkin('CyanideHappiness', GetCandHInfo(), self.prop_prefix)
elif info == 'incinemaRT':
log("start gettin InCinema info")
from MiscScraper import GetRottenTomatoesMovies
passDataToSkin('InCinemaMovies', GetRottenTomatoesMovies("in_theaters"), self.prop_prefix)
elif info == 'boxoffice':
log("start gettin boxoffice info")
from MiscScraper import GetRottenTomatoesMovies
passDataToSkin('BoxOffice', GetRottenTomatoesMovies("box_office"), self.prop_prefix)
elif info == 'opening':
log("start gettin opening info")
from MiscScraper import GetRottenTomatoesMovies
passDataToSkin('Opening', GetRottenTomatoesMovies("opening"), self.prop_prefix)
elif info == 'upcoming':
log("start gettin upcoming info")
# from MiscScraper import GetRottenTomatoesMovies
# passDataToSkin('UpcomingMovies', GetRottenTomatoesMovies("upcoming"), self.prop_prefix, True)
from TheMovieDB import GetMovieDBMovies
passDataToSkin('UpcomingMovies', GetMovieDBMovies("upcoming"), self.prop_prefix)
elif info == 'incinema':
log("start gettin InCinemaMovies info")
from TheMovieDB import GetMovieDBMovies
passDataToSkin('InCinemaMovies', GetMovieDBMovies("now_playing"), self.prop_prefix)
elif info == 'popular':
log("start gettin popularmovies info")
from TheMovieDB import GetMovieDBMovies
passDataToSkin('PopularMovies', GetMovieDBMovies("popular"), self.prop_prefix)
elif info == 'toprated':
log("start gettin InCinemaMovies info")
from TheMovieDB import GetMovieDBMovies
passDataToSkin('TopRatedMovies', GetMovieDBMovies("top_rated"), self.prop_prefix)
elif info == 'toprentals':
log("start gettin toprentals info")
from MiscScraper import GetRottenTomatoesMovies
passDataToSkin('TopRentals', GetRottenTomatoesMovies("top_rentals"), self.prop_prefix)
elif info == 'similarmovies':
log("startin MovieDBGetSimilarMovies")
passDataToSkin('SimilarMovies', None, self.prop_prefix)
from TheMovieDB import GetSimilarMovies
# MovieId = GetDatabaseID(self.id)
if self.id:
MovieId = self.id
elif self.dbid:
MovieId = GetDatabaseID("movie",self.dbid)
log("IMDBId from local DB:" + str(MovieId))
else:
MovieId = ""
if MovieId:
passDataToSkin('SimilarMovies', GetSimilarMovies(MovieId), self.prop_prefix)
elif info == 'movielists':
passDataToSkin('MovieLists', None, self.prop_prefix)
if self.dbid:
log("startin movielists")
from TheMovieDB import GetMovieLists
id = GetDatabaseID("movie",self.dbid)
log("MovieDB Id:" + str(id))
if id:
passDataToSkin('MovieLists', GetMovieLists(id), self.prop_prefix)
elif info == 'keywords':
passDataToSkin('Keywords', None, self.prop_prefix)
if self.dbid:
log("startin Keywords")
from TheMovieDB import GetMovieKeywords
id = GetDatabaseID("movie",self.dbid)
log("MovieDB Id:" + str(id))
if id:
passDataToSkin('Keywords', GetMovieKeywords(id), self.prop_prefix)
elif info == 'extendedinfo':
log("startin GetExtendedMovieInfo")
if self.id:
MovieId = self.id
elif self.dbid:
MovieId = GetDatabaseID("movie",self.dbid)
log("IMDBId from local DB:" + str(MovieId))
else:
MovieId = ""
if MovieId:
from TheMovieDB import GetExtendedMovieInfo
passHomeDataToSkin(GetExtendedMovieInfo(MovieId))
elif info == 'extendedtvinfo':
if self.id:
log("startin GetTVShowInfo")
from MiscScraper import GetTVShowInfo
passHomeDataToSkin(GetTVShowInfo(self.id)[0])
elif info == 'directormovies':
passDataToSkin('DirectorMovies', None, self.prop_prefix)
if self.director:
log("startin GetDirectorMovies")
from TheMovieDB import GetDirectorMovies, GetPersonID
id = GetPersonID(self.director)
if id:
passDataToSkin('DirectorMovies', GetDirectorMovies(id), self.prop_prefix)
elif info == 'writermovies':
passDataToSkin('WriterMovies', None, self.prop_prefix)
if self.writer and not self.writer.split(" / ")[0] == self.director.split(" / ")[0]:
log("startin GetWriterMovies")
from TheMovieDB import GetDirectorMovies, GetPersonID
id = GetPersonID(self.writer)
if id:
passDataToSkin('WriterMovies', GetDirectorMovies(id), self.prop_prefix)
elif info == 'similar':
passDataToSkin('SimilarMovies', None, self.prop_prefix)
log("startin GetSimilarTrakt")
log(self.dbid)
log(self.id)
log(self.type)
from MiscScraper import GetSimilarTrakt
if self.type and (self.id or self.dbid):
if self.dbid:
id = GetDatabaseID(self.type,self.dbid)
log("SimilarTrakt: found dbid " + str(id))
else:
id = self.id
passDataToSkin('SimilarMovies', GetSimilarTrakt(self.type,id), self.prop_prefix)
elif info == 'airingshows':
log("startin GetTraktCalendarShows")
from MiscScraper import GetTraktCalendarShows
passDataToSkin('AiringShows', GetTraktCalendarShows("shows"), self.prop_prefix)
elif info == 'premiereshows':
log("startin GetTraktCalendarShows")
from MiscScraper import GetTraktCalendarShows
passDataToSkin('PremiereShows', GetTraktCalendarShows("premieres"), self.prop_prefix)
elif info == 'trendingshows':
log("startin GetTrendingShows")
from MiscScraper import GetTrendingShows
passDataToSkin('TrendingShows', GetTrendingShows(), self.prop_prefix)
elif info == 'trendingmovies':
log("startin GetTrendingMovies")
from MiscScraper import GetTrendingMovies
passDataToSkin('TrendingMovies', GetTrendingMovies(), self.prop_prefix)
elif info == 'similarartistsinlibrary':
from Utils import GetSimilarArtistsInLibrary
passDataToSkin('SimilarArtistsInLibrary', None, self.prop_prefix)
passDataToSkin('SimilarArtists', GetSimilarArtistsInLibrary(self.Artist_mbid), self.prop_prefix)
elif info == 'artistevents':
passDataToSkin('ArtistEvents', None, self.prop_prefix)
from OnlineMusicInfo import GetEvents
# events = GetEvents(self.Artist_mbid)
passDataToSkin('ArtistEvents', GetEvents(self.Artist_mbid), self.prop_prefix)
elif info == 'youtubesearch':
passDataToSkin('YoutubeSearch', None, self.prop_prefix)
from MiscScraper import GetYoutubeSearchVideos
# events = GetEvents(self.Artist_mbid)
passDataToSkin('YoutubeSearch', GetYoutubeSearchVideos(self.id,self.hd,self.orderby,self.time), self.prop_prefix)
elif info == 'youtubeusersearch':
passDataToSkin('YoutubeUserSearch', None, self.prop_prefix)
from MiscScraper import GetYoutubeUserVideos
passDataToSkin('YoutubeUserSearch', GetYoutubeUserVideos(self.id), self.prop_prefix,True)
elif info == 'nearevents':
passDataToSkin('NearEvents', None, self.prop_prefix)
from OnlineMusicInfo import GetNearEvents
passDataToSkin('NearEvents', GetNearEvents(self.tag,self.festivalsonly), self.prop_prefix)
elif info == 'venueevents':
passDataToSkin('VenueEvents', None, self.prop_prefix)
from OnlineMusicInfo import GetVenueEvents
passDataToSkin('VenueEvents', GetVenueEvents(self.id), self.prop_prefix)
elif info == 'topartistsnearevents':
from Utils import GetXBMCArtists
from OnlineMusicInfo import GetArtistNearEvents
passDataToSkin('TopArtistsNearEvents', None, self.prop_prefix)
artists = GetXBMCArtists()
events = GetArtistNearEvents(artists["result"]["artists"][0:15])
passDataToSkin('TopArtistsNearEvents', events, self.prop_prefix)
elif info == 'updatexbmcdatabasewithartistmbidbg':
from MusicBrainz import SetMusicBrainzIDsForAllArtists
SetMusicBrainzIDsForAllArtists(False, 'forceupdate' in AdditionalParams)
elif info == 'updatexbmcdatabasewithartistmbid':
from MusicBrainz import SetMusicBrainzIDsForAllArtists
SetMusicBrainzIDsForAllArtists(True, 'forceupdate' in AdditionalParams)
elif info == 'getlocationevents':
from OnlineMusicInfo import GetNearEvents
wnd = xbmcgui.Window(Window)
lat = wnd.getProperty('%slat' % self.prop_prefix)
lon = wnd.getProperty('%slon' % self.prop_prefix)
passDataToSkin('NearEvents', GetNearEvents(self.tag,self.festivalsonly,lat,lon), self.prop_prefix)
elif info == 'getgooglemap' or info == 'getgooglestreetviewmap':
direction = ""
from MiscScraper import GetGoogleMap, GetGeoCodes, string2deg
wnd = xbmcgui.Window(Window)
if self.location == "geocode": # convert Image Coordinates to float values
self.lat = string2deg(self.lat)
self.lon = string2deg(self.lon)
log(self.lat)
log(self.lon)
if info == 'getgooglemap': # request normal map
image = GetGoogleMap(mode = "normal",search_string = self.location,zoomlevel = self.zoomlevel,type = self.type,aspect = self.aspect, lat=self.lat,lon=self.lon,direction = self.direction)
overview = ""
else: # request streetview
direction = str(int(self.direction) * 18)
image = GetGoogleMap(mode = "streetview",search_string = self.location,aspect = self.aspect,type = self.type, lat = self.lat,lon = self.lon,zoomlevel = self.zoomlevel,direction = direction)
overview = GetGoogleMap(mode = "normal",search_string = self.location,aspect = self.aspect,type = "roadmap", lat = self.lat,lon = self.lon,zoomlevel = "17",direction = direction)
wnd.setProperty('%sgooglemap' % self.prop_prefix, image) # set properties
wnd.setProperty('%sgooglemapoverview' % self.prop_prefix, overview)
wnd.setProperty('%sDirection' % self.prop_prefix, str(self.direction))
wnd.setProperty('%sDirection2' % self.prop_prefix, str(direction))
if not self.lat or self.location=="geocode": # set properties for lat / lon (after JSON call for speed)
lat = self.lat
lon = self.lon
if not self.location=="geocode":
lat, lon = GetGeoCodes(self.location)
wnd.setProperty('%slat' % self.prop_prefix, str(lat))
wnd.setProperty('%slon' % self.prop_prefix, str(lon))
wnd.setProperty('%sLocation' % self.prop_prefix, "")
elif "move" in info and "google" in info:
from MiscScraper import GetGoogleMap
wnd = xbmcgui.Window(Window)
lat = wnd.getProperty('%slat' % self.prop_prefix)
lon = wnd.getProperty('%slon' % self.prop_prefix)
direction = int(self.direction) * 18
if lat and lon:
if "street" in info:
from math import sin, cos, radians
stepsize = 0.0002
radiantdirection = radians(float(direction))
if "up" in info:
lat = float(lat) + cos(radiantdirection) * stepsize
lon = float(lon) + sin(radiantdirection) * stepsize
elif "down" in info:
lat = float(lat) - cos(radiantdirection) * stepsize
lon = float(lon) - sin(radiantdirection) * stepsize
elif "left" in info:
lat = float(lat) - sin(radiantdirection) * stepsize
lon = float(lon) - cos(radiantdirection) * stepsize
elif "right" in info:
lat = float(lat) + sin(radiantdirection) * stepsize
lon = float(lon) + cos(radiantdirection) * stepsize
else:
stepsize = 200.0 / float(self.zoomlevel) / float(self.zoomlevel) / float(self.zoomlevel) / float(self.zoomlevel)
if "up" in info:
lat = float(lat) + stepsize
elif "down" in info:
lat = float(lat) - stepsize
elif "left" in info:
lon = float(lon) - 2.0 * stepsize
elif "right" in info:
lon = float(lon) + 2.0 * stepsize
self.location = str(lat) + "," + str(lon)
if "street" in info:
image = GetGoogleMap(mode = "streetview",search_string = self.location,zoomlevel = self.zoomlevel,type = self.type,aspect = self.aspect, lat=self.lat,lon=self.lon,direction = direction)
overview = GetGoogleMap(mode = "normal",search_string = self.location,aspect = self.aspect,type = "roadmap", lat = self.lat,lon = self.lon,zoomlevel = "17",direction = self.direction)
else:
image = GetGoogleMap(mode = "normal",search_string = self.location,zoomlevel = self.zoomlevel,type = self.type,aspect = self.aspect, lat=self.lat,lon=self.lon,direction = self.direction)
overview = ""
wnd.setProperty('%sgooglemap' % self.prop_prefix, image)
wnd.setProperty('%sgooglemapoverview' % self.prop_prefix, overview)
wnd.setProperty('%slat' % self.prop_prefix, str(lat))
wnd.setProperty('%sDirection' % self.prop_prefix, self.direction)
wnd.setProperty('%slon' % self.prop_prefix, str(lon))
if not self.silent:
xbmc.executebuiltin( "Dialog.Close(busydialog)" )
def _selection_dialog(self):
modeselect= []
modeselect.append( __language__(32001) )
modeselect.append( __language__(32002) )
modeselect.append( __language__(32003) )
modeselect.append( __language__(32014) )
modeselect.append( __language__(32015) )
# modeselect.append( __language__(32014) + " (TV)" )
modeselect.append( __language__(32015) + " (TV)" )
modeselect.append( "Update All" )
dialogSelection = xbmcgui.Dialog()
selection = dialogSelection.select( __language__(32004), modeselect )
if selection == 0:
from Utils import export_skinsettings
export_skinsettings()
elif selection == 1:
from Utils import import_skinsettings
import_skinsettings()
elif selection == 2:
xbmc.executebuiltin("Skin.ResetSettings")
elif selection == 3:
from Utils import AddArtToLibrary
AddArtToLibrary("extrathumb","Movie", "extrathumbs",extrathumb_limit)
elif selection == 4:
from Utils import AddArtToLibrary
AddArtToLibrary("extrafanart","Movie", "extrafanart",extrafanart_limit)
# elif selection == 5:
# AddArtToLibrary("extrathumb","TVShow", "extrathumbs")
elif selection == 5:
from Utils import AddArtToLibrary
AddArtToLibrary("extrafanart","TVShow", "extrafanart",extrafanart_limit)
elif selection == 6:
from Utils import AddArtToLibrary
AddArtToLibrary("extrathumb","Movie", "extrathumbs",extrathumb_limit)
AddArtToLibrary("extrafanart","Movie", "extrafanart",extrafanart_limit)
AddArtToLibrary("extrafanart","TVShow", "extrafanart",extrafanart_limit)
def _init_vars(self):
self.window = xbmcgui.Window(10000) # Home Window
self.cleared = False
self.musicvideos = []
self.movies = []
self.infos = []
self.AlbumName = None
self.ArtistName = None
self.UserName = None
self.feed = None
self.id = None
self.dbid = None
self.setid = None
self.type = False
self.hd = ""
self.direction = 0
self.aspect = "Landscape"
self.orderby = "relevance"
self.time = "all_time"
self.zoomlevel = "15"
self.location = ""
self.director = ""
self.tag = ""
self.writer = ""
self.studio = ""
self.lat = ""
self.lon = ""
self.silent = True
self.festivalsonly = False
self.prop_prefix = ""
self.Artist_mbid = None
self.window.clearProperty('SongToMusicVideo.Path')
def _parse_argv(self):
try:
params = dict( arg.split("=") for arg in sys.argv[1].split("&"))
except:
params = {}
self.artistid = -1
try: self.artistid = int(params.get("artistid", "-1"))
except: pass
self.backend = params.get("backend", False)
self.exportsettings = params.get("exportsettings", False)
self.importsettings = params.get("importsettings", False)
self.importextrathumb = params.get("importextrathumb", False)
self.importextrathumbtv = params.get("importextrathumbtv", False)
self.importextrafanart = params.get("importextrafanart", False)
self.importextrafanarttv = params.get("importextrafanarttv", False)
self.importallartwork = params.get("importallartwork", False)
for arg in sys.argv:
log(arg)
if arg == 'script.extendedinfo':
continue
param = arg.lower()
if param.startswith('info='):
self.infos.append(param[5:])
elif param.startswith('type='):
self.type = (param[5:])
elif param.startswith('tag='):
self.tag = (param[4:])
elif param.startswith('direction='):
self.direction = (param[10:])
elif param.startswith('aspect='):
self.aspect = (param[7:])
elif param.startswith('zoomlevel='):
self.zoomlevel = (param[10:])
elif param.startswith('location='):
self.location = (param[9:])
elif param.startswith('studio='):
self.studio = (param[7:])
elif param.startswith('orderby='):
self.orderby = (param[8:])
elif param.startswith('time='):
self.time = (param[5:])
elif param.startswith('director='):
self.director = (param[9:])
elif param.startswith('writer='):
self.writer = (param[7:])
elif param.startswith('lat='):
self.lat = (param[4:])
elif param.startswith('lon='):
self.lon = (param[4:])
elif param.startswith('silent='):
self.silent = (param[7:])
if self.silent == "false":
self.silent = False
elif param.startswith('festivalsonly='):
self.festivalsonly = (param[14:])
elif param.startswith('feed='):
self.feed = param[5:]
elif param.startswith('id='):
self.id = param[3:]
elif param.startswith('dbid='):
self.dbid = param[5:]
elif param.startswith('setid='):
self.setid = param[6:]
elif param.startswith('hd='):
self.hd = param[3:]
elif param.startswith('prefix='):
self.prop_prefix = param[7:]
if not self.prop_prefix.endswith('.') and self.prop_prefix <> "":
self.prop_prefix = self.prop_prefix + '.'
elif param.startswith('artistname='):
self.ArtistName = arg[11:].replace('"','')
if self.ArtistName:
# todo: look up local mbid first -->xbmcid for parameter
from MusicBrainz import GetMusicBrainzIdFromNet
self.Artist_mbid = GetMusicBrainzIdFromNet(self.ArtistName)
elif param.startswith('albumname='):
self.AlbumName = arg[10:].replace('"','')
elif param.startswith('username='):
self.UserName = arg[9:].replace('"','')
elif param.startswith('tracktitle='):
TrackTitle = arg[11:].replace('"','')
elif param.startswith('window='):
Window = int(arg[7:])
elif param.startswith('setuplocation'):
settings = xbmcaddon.Addon(id='script.extendedinfo')
country = settings.getSetting('country')
city = settings.getSetting('city')
log('stored country/city: %s/%s' % (country, city) )
kb = xbmc.Keyboard('', __language__(32013) + ":")
kb.doModal()
country = kb.getText()
kb = xbmc.Keyboard('', __language__(32012) + ":")
kb.doModal()
city = kb.getText()
log('country/city: %s/%s' % (country, city) )
settings.setSetting('location_method', 'country_city')
settings.setSetting('country',country)
settings.setSetting('city',city)
log('done with settings')
else:
AdditionalParams.append(param)
def _set_detail_properties( self, movie,count):
self.window.setProperty('Detail.Movie.%i.Path' % (count), movie["file"])
self.window.setProperty('Detail.Movie.%i.Art(fanart)' % (count), movie["art"].get('fanart',''))
self.window.setProperty('Detail.Movie.%i.Art(poster)' % (count), movie["art"].get('poster',''))
def _detail_selector( self, comparator):
self.selecteditem = xbmc.getInfoLabel("ListItem.Label")
if (self.selecteditem != self.previousitem):
if xbmc.getCondVisibility("!Stringcompare(ListItem.Label,..)"):
self.previousitem = self.selecteditem
self._clear_properties()
count = 1
for movie in self.movies["result"]["movies"]:
log(comparator)
if self.selecteditem in str(movie[comparator]):
log(movie)
self._set_detail_properties(movie,count)
count +=1
if count > 19:
break
else:
self._clear_properties()
def run_backend(self):
self._stop = False
self.previousitem = ""
self.previousartist = ""
self.previoussong = ""
from Utils import create_musicvideo_list, create_movie_list
self.musicvideos = create_musicvideo_list()
self.movies = create_movie_list()
while (not self._stop) and (not xbmc.abortRequested):
if xbmc.getCondVisibility("Container.Content(movies) | Container.Content(sets) | Container.Content(artists) | Container.Content(albums)"):
self.selecteditem = xbmc.getInfoLabel("ListItem.DBID")
if (self.selecteditem != self.previousitem):
self.previousitem = self.selecteditem
if xbmc.getCondVisibility("!IsEmpty(ListItem.DBID) + [SubString(ListItem.Path,videodb://1/7/,left)| Container.Content(artists) | Container.Content(albums)]"):
self._set_details(xbmc.getInfoLabel("ListItem.DBID"))
log("setting movieset labels")
else:
self._clear_properties()
elif xbmc.getCondVisibility("Container.Content(years)"):
self._detail_selector("year")
elif xbmc.getCondVisibility("Container.Content(genres)"):
self._detail_selector("genre")
elif xbmc.getCondVisibility("Container.Content(directors)"):
self._detail_selector("director")
elif xbmc.getCondVisibility("Container.Content(actors)"):
self._detail_selector("cast")
elif xbmc.getCondVisibility("Container.Content(studios)"):
self._detail_selector("studio")
elif xbmc.getCondVisibility("Container.Content(countries)"):
self._detail_selector("country")
elif xbmc.getCondVisibility("Container.Content(tags)"):
self._detail_selector("tag")
elif xbmc.getCondVisibility('Container.Content(songs)') and self.musicvideos:
# get artistname and songtitle of the selected item
self.selecteditem = xbmc.getInfoLabel('ListItem.DBID')
# check if we've focussed a new song
if self.selecteditem != self.previousitem:
self.previousitem = self.selecteditem
# clear the window property
self.window.clearProperty('SongToMusicVideo.Path')
# iterate through our musicvideos
for musicvideo in self.musicvideos:
if self.selecteditem == musicvideo[0]:#needs fixing
# match found, set the window property
self.window.setProperty('SongToMusicVideo.Path', musicvideo[2])
xbmc.sleep(100)
# stop iterating
break
elif xbmc.getCondVisibility("Window.IsActive(visualisation)"):
self.selecteditem = xbmc.getInfoLabel('MusicPlayer.Artist')
if (self.selecteditem != self.previousitem) and self.selecteditem:
self.previousitem = self.selecteditem
from MusicBrainz import GetMusicBrainzIdFromNet
from Utils import GetSimilarArtistsInLibrary
log("Daemon updating SimilarArtists")
Artist_mbid = GetMusicBrainzIdFromNet(self.selecteditem)
passDataToSkin('SimilarArtistsInLibrary', None, self.prop_prefix)
passDataToSkin('SimilarArtists', GetSimilarArtistsInLibrary(Artist_mbid), self.prop_prefix)
elif xbmc.getCondVisibility('Window.IsActive(screensaver)'):
xbmc.sleep(1000)
else:
self.previousitem = ""
self.selecteditem = ""
self._clear_properties()
xbmc.sleep(500)
if xbmc.getCondVisibility("IsEmpty(Window(home).Property(extendedinfo_backend_running))"):
self._clear_properties()
self._stop = True
xbmc.sleep(100)
def _set_details( self, dbid ):
if dbid:
try:
b = ""
if xbmc.getCondVisibility('Container.Content(artists)') or self.type == "artist":
a = datetime.datetime.now()
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioLibrary.GetAlbums", "params": {"properties": ["title", "year", "albumlabel", "playcount", "thumbnail"], "sort": { "method": "label" }, "filter": {"artistid": %s} }, "id": 1}' % dbid)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
self._clear_properties()
if json_query['result'].has_key('albums'):
self._set_artist_properties(json_query)
b = datetime.datetime.now() - a
elif xbmc.getCondVisibility('Container.Content(albums)') or self.type == "album":
a = datetime.datetime.now()
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "AudioLibrary.GetSongs", "params": {"properties": ["title", "track", "duration", "file", "lastplayed", "disc"], "sort": { "method": "label" }, "filter": {"albumid": %s} }, "id": 1}' % dbid)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
self._clear_properties()
if "result" in json_query and json_query['result'].has_key('songs'):
self._set_album_properties(json_query)
b = datetime.datetime.now() - a
elif xbmc.getCondVisibility('[Container.Content(movies) + ListItem.IsFolder] | Container.Content(sets)') or self.type == "set":
a = datetime.datetime.now()
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMovieSetDetails", "params": {"setid": %s, "properties": [ "thumbnail" ], "movies": { "properties": [ "rating", "art", "file", "year", "director", "writer","genre" , "thumbnail", "runtime", "studio", "plotoutline", "plot", "country"], "sort": { "order": "ascending", "method": "year" }} },"id": 1 }' % dbid)
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
self._clear_properties()
if "result" in json_query and json_query['result'].has_key('setdetails'):
self._set_movie_properties(json_query)
b = datetime.datetime.now() - a
elif xbmc.getCondVisibility('Container.Content(songs)') or self.type == "songs":
a = datetime.datetime.now()
json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetMusicVideos", "params": {"properties": ["artist", "file"], "sort": { "method": "artist" } }, "id": 1}')
json_query = unicode(json_query, 'utf-8', errors='ignore')
json_query = simplejson.loads(json_query)
self._clear_properties()
if "result" in json_query and json_query['result'].has_key('musicvideos'):
self._set_movie_properties(json_query)
b = datetime.datetime.now() - a
if b:
log('Total time needed to request: %s' % b)
except Exception, e:
log(e)
def _set_artist_properties( self, audio ):
count = 1
latestyear = 0
firstyear = 0
playcount = 0
for item in audio['result']['albums']:
self.window.setProperty('Artist.Album.%d.Title' % count, item['title'])
self.window.setProperty('Artist.Album.%d.Year' % count, str(item['year']))
self.window.setProperty('Artist.Album.%d.Thumb' % count, item['thumbnail'])
self.window.setProperty('Artist.Album.%d.DBID' % count, str(item.get('albumid')))
self.window.setProperty('Artist.Album.%d.Label' % count, item['albumlabel'])
if item['playcount']:
playcount = playcount + item['playcount']
if item['year']:
if item['year'] > latestyear:
latestyear = item['year']
if firstyear == 0 or item['year'] < firstyear:
firstyear = item['year']
count += 1
self.window.setProperty('Artist.Albums.Newest', str(latestyear))
self.window.setProperty('Artist.Albums.Oldest', str(firstyear))
self.window.setProperty('Artist.Albums.Count', str(audio['result']['limits']['total']))
self.window.setProperty('Artist.Albums.Playcount', str(playcount))
self.cleared = False
def _set_album_properties( self, json_query ):
count = 1
duration = 0
discnumber = 0
tracklist=""
for item in json_query['result']['songs']:
self.window.setProperty('Album.Song.%d.Title' % count, item['title'])
tracklist += "[B]" + str(item['track']) + "[/B]: " + item['title'] + "[CR]"
array = item['file'].split('.')
self.window.setProperty('Album.Song.%d.FileExtension' % count, str(array[-1]))
if item['disc'] > discnumber:
discnumber = item['disc']
duration += item['duration']
count += 1
self.window.setProperty('Album.Songs.Discs', str(discnumber))
self.window.setProperty('Album.Songs.Duration', str(duration))
self.window.setProperty('Album.Songs.Tracklist', tracklist)
self.window.setProperty('Album.Songs.Count', str(json_query['result']['limits']['total']))
self.cleared = False
def _set_movie_properties( self, json_query ):
count = 1
runtime = 0
writer = []
director = []
genre = []
country = []
studio = []
years = []
plot = ""
title_list = ""
title_list += "[B]" + str(json_query['result']['setdetails']['limits']['total']) + " " + xbmc.getLocalizedString(20342) + "[/B][CR][I]"
from Utils import media_path
for item in json_query['result']['setdetails']['movies']:
art = item['art']
self.window.setProperty('Set.Movie.%d.DBID' % count, str(item.get('movieid')))
self.window.setProperty('Set.Movie.%d.Title' % count, item['label'])
self.window.setProperty('Set.Movie.%d.Plot' % count, item['plot'])
self.window.setProperty('Set.Movie.%d.PlotOutline' % count, item['plotoutline'])
self.window.setProperty('Set.Movie.%d.Path' % count, media_path(item['file']))
self.window.setProperty('Set.Movie.%d.Year' % count, str(item['year']))
self.window.setProperty('Set.Movie.%d.Duration' % count, str(item['runtime']/60))
self.window.setProperty('Set.Movie.%d.Art(clearlogo)' % count, art.get('clearlogo',''))
self.window.setProperty('Set.Movie.%d.Art(discart)' % count, art.get('discart',''))
self.window.setProperty('Set.Movie.%d.Art(fanart)' % count, art.get('fanart',''))
self.window.setProperty('Detail.Movie.%d.Art(fanart)' % count, art.get('fanart',''))
self.window.setProperty('Set.Movie.%d.Art(poster)' % count, art.get('poster',''))
self.window.setProperty('Detail.Movie.%d.Art(poster)' % count, art.get('poster',''))
title_list += item['label'] + " (" + str(item['year']) + ")[CR]"
if item['plotoutline']:
plot += "[B]" + item['label'] + " (" + str(item['year']) + ")[/B][CR]" + item['plotoutline'] + "[CR][CR]"
else:
plot += "[B]" + item['label'] + " (" + str(item['year']) + ")[/B][CR]" + item['plot'] + "[CR][CR]"
runtime += item['runtime']
count += 1
if item.get( "writer" ): writer += [ w for w in item[ "writer" ] if w and w not in writer ]
if item.get( "director" ): director += [ d for d in item[ "director" ] if d and d not in director ]
if item.get( "genre" ): genre += [ g for g in item[ "genre" ] if g and g not in genre ]
if item.get( "country" ): country += [ c for c in item[ "country" ] if c and c not in country ]
if item.get( "studio" ): studio += [ s for s in item[ "studio" ] if s and s not in studio ]
years.append(str(item['year']))
self.window.setProperty('Set.Movies.Plot', plot)
if json_query['result']['setdetails']['limits']['total'] > 1:
self.window.setProperty('Set.Movies.ExtendedPlot', title_list + "[/I][CR]" + plot)
else:
self.window.setProperty('Set.Movies.ExtendedPlot', plot)
self.window.setProperty('Set.Movies.Runtime', str(runtime/60))
self.window.setProperty('Set.Movies.Writer', " / ".join( writer ))
self.window.setProperty('Set.Movies.Director', " / ".join( director ))
self.window.setProperty('Set.Movies.Genre', " / ".join( genre ))
self.window.setProperty('Set.Movies.Country', " / ".join( country ))
self.window.setProperty('Set.Movies.Studio', " / ".join( studio ))
self.window.setProperty('Set.Movies.Years', " / ".join( years ))
self.window.setProperty('Set.Movies.Count', str(json_query['result']['setdetails']['limits']['total']))
self.cleared = False
def _clear_properties( self ):
#todo
self.cleared = False
if not self.cleared:
for i in range(1,50):
self.window.clearProperty('Artist.Album.%d.Title' % i)
self.window.clearProperty('Artist.Album.%d.Plot' % i)
self.window.clearProperty('Artist.Album.%d.PlotOutline' % i)
self.window.clearProperty('Artist.Album.%d.Year' % i)
self.window.clearProperty('Artist.Album.%d.Duration' % i)
self.window.clearProperty('Artist.Album.%d.Thumb' % i)
self.window.clearProperty('Artist.Album.%d.ID' % i)
self.window.clearProperty('Album.Song.%d.Title' % i)
self.window.clearProperty('Album.Song.%d.FileExtension' % i)
self.window.clearProperty('Set.Movie.%d.Art(clearlogo)' % i)
self.window.clearProperty('Set.Movie.%d.Art(fanart)' % i)
self.window.clearProperty('Set.Movie.%d.Art(poster)' % i)
self.window.clearProperty('Set.Movie.%d.Art(discart)' % i)
self.window.clearProperty('Detail.Movie.%d.Art(poster)' % i)
self.window.clearProperty('Detail.Movie.%d.Art(fanart)' % i)
self.window.clearProperty('Detail.Movie.%d.Art(Path)' % i)
self.window.clearProperty('Album.Songs.TrackList')
self.window.clearProperty('Album.Songs.Discs')
self.window.clearProperty('Artist.Albums.Newest')
self.window.clearProperty('Artist.Albums.Oldest')
self.window.clearProperty('Artist.Albums.Count')
self.window.clearProperty('Artist.Albums.Playcount')
self.window.clearProperty('Album.Songs.Discs')
self.window.clearProperty('Album.Songs.Duration')
self.window.clearProperty('Album.Songs.Count')
self.window.clearProperty('Set.Movies.Plot')
self.window.clearProperty('Set.Movies.ExtendedPlot')
self.window.clearProperty('Set.Movies.Runtime')
self.window.clearProperty('Set.Movies.Writer')
self.window.clearProperty('Set.Movies.Director')
self.window.clearProperty('Set.Movies.Genre')
self.window.clearProperty('Set.Movies.Years')
self.window.clearProperty('Set.Movies.Count')
self.cleared = True
if ( __name__ == "__main__" ):
Main()
log('finished')