-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdefault.py
More file actions
246 lines (228 loc) · 14 KB
/
default.py
File metadata and controls
246 lines (228 loc) · 14 KB
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
### ############################################################################################################
### #
### # Project: # Dreamcatcher - by The Highway 2014.
### # Author: # The Highway
### # Version: #
### # Description: #
### #
### ############################################################################################################
### ############################################################################################################
##### Imports #####
import os,sys,string,StringIO,logging,random,array,time,datetime,re
import xbmc,urllib,urllib2,xbmcaddon,xbmcplugin,xbmcgui,xbmcvfs
try: import copy
except: pass
from common import *
from common import (_addon,_plugin,_artIcon,_artFanart,_addonPath,_debugging,deb,debob,fixPath)
import common as CoMMoN
### ############################################################################################################
### ############################################################################################################
SiteName='Dreamcatcher'
SiteTag='Dreamcatcher'
mainSite=''
iconSite=_artIcon
fanartSite=_artFanart
CR='[CR]'
MyBrowser=['User-Agent','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3']
### ############################################################################################################
### ############################################################################################################
site=addpr('site','')
section=addpr('section','')
url=addpr('url','')
sections={'series':'series','movies':'movies'}
thumbnail=addpr('img','')
fanart=addpr('fanart','')
page=addpr('page','')
### ############################################################################################################
### ############################################################################################################
def AFColoring(t):
if len(t)==0: return t
elif len(t)==1: return cFL(t,'firebrick')
else: return cFL(cFL_(t,'firebrick'),'mediumpurple')
### ############################################################################################################
### ############################################################################################################
def About(head=''+cFL(SiteName,'blueviolet')+'',m=''):
m=''
if len(m)==0:
m+='IRC Chat: '+cFL('#The_Projects','blueviolet')+' @ '+cFL('irc.snoonet.org:6667','blueviolet')
m+=CR+'Site Name: '+SiteName+CR+'Site Tag: '+SiteTag+CR+'Site Domain: '+mainSite+CR+'Site Icon: '+iconSite+CR+'Site Fanart: '+fanartSite
#m+=CR+'Age: Please make sure you are of a valid age to watch the material shown.'
#m+=CR+CR+'Known Hosts for Videos: '
#m+=CR+'* VideoCrazy'
#m+=CR+'* UploadCrazy'
m+=CR+CR+'Features: '
#m+=CR+'* Browse Shows'
#m+=CR+'* Browse Episodes'
#m+=CR+'* Browse Host Links'
#m+=CR+'* Play Videos with UrlResolver'
#m+=CR+'* Download Videos with UrlResolver'
#m+=CR+'* MetaData for Shows and 1st Season Episodes where data is available.'
#m+=CR+'* MetaData auto-disabled for Anime List - ALL. This is to prevent hammering with the huge list of nearly 400 shows.'
m+=CR+CR+'Notes: '
#m+=CR+'* '
#m+=CR+'* '
m+=CR+''
#m+=CR+ps('ReferalMsg')
m+=CR+'For more information visit the forum: '+cFL('http://forums.addons.center/thread/190-dreamcatcher-addon/','blueviolet')
m+=CR+''
m+=CR+''
String2TextBox(message=cFL(m,'cornflowerblue'),HeaderMessage=head)
### ############################################################################################################
### ############################################################################################################
DT={}; now=datetime.date.today();
DT['year']=now.strftime("%Y"); DT['month']=now.strftime("%m"); DT['day']=now.strftime("%d");
debob(DT);
def setupName(vName,pType,vUrl):
if pType=='Video':
try: pTVShowTitle=xbmc.getInfoLabel('VideoPlayer.TVShowTitle');
except: pTVShowTitle='';
try: pTitle=xbmc.getInfoLabel('VideoPlayer.Title');
except: pTitle='';
if len(pTitle)==0:
try: pTitle=p.getVideoInfoTag().getTitle();
except: pTitle='';
try: pIMDBno=p.getVideoInfoTag().getIMDBNumber(); pIMDBno=str(pIMDBno).strip();
except: pIMDBno='';
try: pStudio=xbmc.getInfoLabel('VideoPlayer.Studio');
except: pStudio='';
pStudio=pStudio.strip(); pTVShowTitle=pTVShowTitle.strip(); pTitle=pTitle.strip();
vName=vName.strip();
if len(pTitle) > 0: vName+=pTitle
vName=vName.strip();
if (tfalse(addst('name-tvshowtitle','true'))==True) and (len(pTitle) > 0) and (len(pTVShowTitle) > 0): vName=pTVShowTitle+' - '+vName
vName=vName.strip();
if (tfalse(addst('name-studio','true'))==True) and (len(pTitle) > 0) and (len(pStudio) > 0): vName=pStudio+' - '+vName
elif (tfalse(addst('name-studio','true'))==True) and (len(pTitle)==0) and (len(pStudio) > 0): vName=pStudio+vName
elif pType=='Audio':
#try: pTitle=p.getMusicInfoTag().getTitle();
try: pTitle=xbmc.getInfoLabel('MusicPlayer.Title');
except: pTitle='';
try: pStudio=xbmc.getInfoLabel('MusicPlayer.Artist');
except: pStudio='';
pTVShowTitle=''; pIMDBno='';
pStudio=pStudio.strip(); pTVShowTitle=pTVShowTitle.strip(); pTitle=pTitle.strip();
if len(pTitle) > 0: vName+=pTitle
#if (tfalse(addst('name-tvshowtitle','true'))==True) and (len(pTitle) > 0) and (len(pTVShowTitle) > 0): vName=pTVShowTitle+' - '+vName
vName=vName.strip();
if (tfalse(addst('name-artist','true'))==True) and (len(pTitle) > 0) and (len(pStudio) > 0): vName=pStudio+' - '+vName
elif (tfalse(addst('name-artist','true'))==True) and (len(pTitle)==0) and (len(pStudio) > 0): vName=pStudio+vName
else:
pTVShowTitle=''; pTitle=''; pStudio=''; vName='[Unknown]';
pStudio=pStudio.strip(); pTVShowTitle=pTVShowTitle.strip(); pTitle=pTitle.strip();
p=xbmc.Player();
#pStudio=pStudio.strip(); pTVShowTitle=pTVShowTitle.strip(); pTitle=pTitle.strip();
#if len(pTitle) > 0: vName+=pTitle
#if (tfalse(addst('name-tvshowtitle','true'))==True) and (len(pTitle) > 0) and (len(pTVShowTitle) > 0): vName=pTVShowTitle+' - '+vName
#if (tfalse(addst('name-studio','true'))==True) and (len(pTitle) > 0) and (len(pStudio) > 0): vName=pStudio+' - '+vName
#elif (tfalse(addst('name-studio','true'))==True) and (len(pTitle)==0) and (len(pStudio) > 0): vName=pStudio+vName
vName=vName.replace('!','').replace('"','').replace(':','').replace(';','').replace('|','').replace('/','').replace('\\','').replace(' ',' ')
vName=vName.replace('[B]','').replace('[/B]','').replace('[I]','').replace('[/I]','').replace('[CR]','').replace('[/COLOR]','')
for C1 in ["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","honeydew","hotpink","indianred ","indigo ","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","none","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"]: vName=vName.replace('[COLOR '+C1+']','')
vName=vName.strip();
if tfalse(addst('name-datestamp','true'))==True: vName+=' - ['+DT['year']+'-'+DT['month']+'-'+DT['day']+']';
vName=vName.strip();
if pType=='Video':
if '.mpg' in vUrl: vName+='.mpg';
elif '.mpeg' in vUrl: vName+='.mpeg';
elif '.mp4' in vUrl: vName+='.mp4';
elif '.avi' in vUrl: vName+='.avi';
elif '.wmv' in vUrl: vName+='.wmv';
elif '.flv' in vUrl: vName+='.flv';
#elif '.' in vUrl: vName+='.';
else: vName+='.flv';
elif pType=='Audio':
if '.mp3' in vUrl: vName+='.mp3';
elif '.ogg' in vUrl: vName+='.ogg';
elif '.mid' in vUrl: vName+='.mid';
elif '.midi' in vUrl: vName+='.midi';
elif '.wav' in vUrl: vName+='.wav';
else: vName+='.mp3';
else:
if '.bmp' in vUrl: vName+='.bmp';
elif '.jpg' in vUrl: vName+='.jpg';
elif '.jpeg' in vUrl: vName+='.jpeg';
elif '.png' in vUrl: vName+='.png';
elif '.gif' in vUrl: vName+='.gif';
elif '.psd' in vUrl: vName+='.psd';
else: vName+='.FLV';
vName=vName.strip();
return vName
def startStreamRecord():
vName=''; vPath=''; p=xbmc.Player();
if (p.isPlayingVideo()==True): pType='Video'; debob("isPlayingVideo"); vPath=addst('download_folder_default','');
elif (p.isPlayingAudio()==True):
pType='Audio'; debob("isPlayingAudio"); vPath=addst('download_folder_audio','');
if len(vPath)==0: vPath=addst('download_folder_default','');
elif (p.isPlaying()==True): pType='Unknown'; debob("isPlaying"); vPath=addst('download_folder_default','');
else: pType=''; debob("Couldn't find anything playing."); vPath=addst('download_folder_default','');
try:
if (p.isInternetStream()==True): iIS=True; deb("isInternetStream()","True");
else: iIS=False; deb("isInternetStream()","False");
except: iIS=True; deb("isInternetStream()","error");
if (len(vPath) > 0) and (len(pType) > 0) and (iIS==True):
vPath=fixPath(vPath); deb("vPath",vPath);
vUrl=xbmc.Player().getPlayingFile(); deb("vUrl",vUrl);
vName=setupName(vName,pType,vUrl);
###
eod(); DoA("Back");
DownloadThis(vUrl,vName,vPath,False);
else: eod(); DoA("Back");
def SectionMenu():
vName=''; vPath=''; p=xbmc.Player();
if (p.isPlayingVideo()==True): pType='Video'; debob("isPlayingVideo"); vPath=addst('download_folder_default','');
elif (p.isPlayingAudio()==True):
pType='Audio'; debob("isPlayingAudio"); vPath=addst('download_folder_audio','');
if len(vPath)==0: vPath=addst('download_folder_default','');
elif (p.isPlaying()==True): pType='Unknown'; debob("isPlaying"); vPath=addst('download_folder_default','');
else: pType=''; debob("Couldn't find anything playing."); vPath=addst('download_folder_default','');
try:
if (p.isInternetStream()==True): iIS=True; deb("isInternetStream()","True");
else: iIS=False; deb("isInternetStream()","False");
except: iIS=True; deb("isInternetStream()","error");
if (len(vPath) > 0) and (len(pType) > 0) and (iIS==True):
vPath=fixPath(vPath); deb("vPath",vPath);
vUrl=xbmc.Player().getPlayingFile(); deb("vUrl",vUrl);
vName=setupName(vName,pType,vUrl);
###
_addon.add_directory({'mode':'Download','url':vUrl,'destfile':vName,'filetype':pType,'destpath':vPath,'site':site,'section':section},{'title':cFL('Download '+str(pType)+': ','firebrick')+cFL(vName,'mediumpurple')+CR+vUrl},is_folder=True,fanart=fanartSite,img=iconSite)
###
_addon.add_directory({'mode':'About','site':site,'section':section},{'title':AFColoring('About')},is_folder=True,fanart=fanartSite,img='http://i.imgur.com/0h78x5V.png') # iconSite
set_view('list',view_mode=addst('default-view')); eod()
### ############################################################################################################
### ############################################################################################################
def mode_subcheck(mode='',site='',section='',url=''):
deb('mode',mode);
if (mode=='SectionMenu') or (mode=='') or (mode=='main') or (mode=='MainMenu'): SectionMenu()
elif (mode=='Record'): startStreamRecord()
## XBMC.Container.Update(plugin://plugin.program.streamrecord/?mode=Record)
## XBMC.RunPlugin(plugin://plugin.program.streamrecord/?mode=Record) ## this one seems to work in skins.
elif (mode=='Download'):
#try: _addon.resolve_url(url);
#except: pass
#debob([url,addpr('destfile',''),addpr('destpath',''),str(tfalse(addpr('useResolver','true')))]);
#DownloadThis(url,addpr('destfile',''),addpr('destpath',''),tfalse(addpr('useResolver','true')));
destpath=addpr('destpath','')
if len(destpath)==0: destpath=addst('download_folder_default','')
debob([url,addpr('destfile',''),destpath,'False']);
eod(); DoA("Back");
DownloadThis(url,addpr('destfile',''),destpath,False);
elif (mode=='ResolveAndDownload'):
destpath=addpr('destpath','')
if len(destpath)==0: destpath=addst('download_folder_default','')
debob([url,addpr('destfile',''),destpath,'False']);
eod(); DoA("Back");
try: import urlresolver
except: myNote('Problem','unable to import: urlresolver',15000); debob(['Problem','unable to import: urlresolver']); return
try:
oUrl=''+url
url=urlresolver.HostedMediaFile(url).resolve()
except: myNote('Problem','resolving url',15000); debob(['Problem','resolving url',oUrl,url]); return
DownloadThis(url,addpr('destfile',''),destpath,False);
elif (mode=='toJDownloader'):
SendTo_JDownloader(url,tfalse(addpr('useResolver','true')));
eod(); DoA("Back");
elif (mode=='About'): About(); eod(); #DoA("Back");
else: myNote(header='Site: "'+str(site)+'"',msg=str(mode)+' (mode) not found.'); SectionMenu()
mode_subcheck(addpr('mode',''),addpr('site',''),addpr('section',''),addpr('url',''))
### ############################################################################################################
### ############################################################################################################