MasterPuppeteer

Initial implementations commit

Showing 33 changed files with 297 additions and 0 deletions
1 +/*
2 + * Copyright (c) 2017 PuppetMaster.TV
3 + *
4 + * This program is free software; you can redistribute it and/or
5 + * modify it under the terms of the GNU General Public License
6 + * as published by the Free Software Foundation; either version 2
7 + * of the License, or (at your option) any later version.
8 + *
9 + * This program is distributed in the hope that it will be useful,
10 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 + * GNU General Public License for more details:
13 + *
14 + * https://www.gnu.org/licenses/gpl-2.0.txt
15 + */
16 +
17 +/*
18 + * @author MasterPuppeteer
19 + * @credit learningit
20 + */
21 +
22 +package tv.puppetmaster.usa
23 +
24 +import tv.puppetmaster.data.i.*
25 +import tv.puppetmaster.data.i.Puppet.PuppetIterator
26 +import tv.puppetmaster.data.i.SourcesPuppet.SourceDescription
27 +
28 +import java.util.regex.Matcher
29 +
30 +public class CometTVPuppet implements InstallablePuppet {
31 +
32 + static final int VERSION_CODE = 5
33 +
34 + @Override
35 + PuppetIterator getChildren() {
36 + PuppetIterator children = new CometTVPuppetIterator(this)
37 + children.add(new CometTVLiveSourcesPuppet(this))
38 + return children
39 + }
40 +
41 + @Override
42 + boolean isTopLevel() {
43 + return true
44 + }
45 +
46 + @Override
47 + String getName() {
48 + return "Comet TV"
49 + }
50 +
51 + @Override
52 + String getCategory() {
53 + return "Sci-Fi"
54 + }
55 +
56 + @Override
57 + String getShortDescription() {
58 + return "Dedicated to sci-fi entertainment offering popular favorites, cult classics, and undiscovered gems, every day"
59 + }
60 +
61 + @Override
62 + String getImageUrl() {
63 + return "http://static-33.sinclairstoryline.com/resources/media/00cae24d-0f3f-4ae6-bc22-bc78f31fbb99-large16x9_COMET_LOGO_GREEN.jpg"
64 + }
65 +
66 + @Override
67 + String getBackgroundImageUrl() {
68 + return "http://static-12.sinclairstoryline.com/resources/media/00cae24d-0f3f-4ae6-bc22-bc78f31fbb99-large16x9_COMET_LOGO_GREEN.jpg"
69 + }
70 +
71 + @Override
72 + boolean isUnavailableIn(String region) {
73 + return false
74 + }
75 +
76 + @Override
77 + String getPreferredRegion() {
78 + return null
79 + }
80 +
81 + @Override
82 + int getShieldLevel() {
83 + return 0
84 + }
85 +
86 + @Override
87 + ParentPuppet getParent() {
88 + return null
89 + }
90 +
91 + @Override
92 + SearchesPuppet getSearchProvider() {
93 + return null
94 + }
95 +
96 + @Override
97 + SettingsPuppet getSettingsProvider() {
98 + return null
99 + }
100 +
101 + @Override
102 + int getFastlaneBackgroundColor() {
103 + return 0xFF53AC02
104 + }
105 +
106 + @Override
107 + int getSearchAffordanceBackgroundColor() {
108 + return 0xFFBAE704
109 + }
110 +
111 + @Override
112 + int getSelectedBackgroundColor() {
113 + return 0xFF000000
114 + }
115 +
116 + @Override
117 + int getPlayerBackgroundColor() {
118 + return 0xFF53AC02
119 + }
120 +
121 + @Override
122 + List<Map<String, String>> getLiveChannelsMetaData() {
123 + return [[
124 + name: getName(),
125 + description: getShortDescription(),
126 + genres: "ENTERTAINMENT",
127 + logo: getImageUrl(),
128 + url: "http://content.uplynk.com/channel/810bf2b47d9f4bd8a0101dd2b21afc91.m3u8?tc=1&exp=1614631202&rn=1044192764&ct=c&cid=810bf2b47d9f4bd8a0101dd2b21afc91&ad=comet&ad.adUnit=%2FCOMET%2FLivestream_midroll&ad._debug=comet_vmap&ad.ad_rule=1&ad.pmad=10&ad.output=xml_vmap1&sig=61df4f67b54a8b52d2060b9e30bcf4bbe41fe1a1c86bf468377f869a29569b7c"
129 + ]]
130 + }
131 +
132 + @Override
133 + PuppetIterator getRelated() {
134 + return null
135 + }
136 +
137 + @Override
138 + public String toString() {
139 + return getName()
140 + }
141 +
142 + @Override
143 + int getVersionCode() {
144 + return VERSION_CODE
145 + }
146 +
147 + def class CometTVPuppetIterator extends PuppetIterator {
148 +
149 + def ParentPuppet mParent
150 + def ArrayList<Puppet> mPuppets = new ArrayList<>()
151 + def int currentIndex = 0
152 +
153 + public CometTVPuppetIterator(ParentPuppet parent) {
154 + mParent = parent
155 + }
156 +
157 +
158 + @Override
159 + boolean hasNext() {
160 + return currentIndex < mPuppets.size()
161 + }
162 +
163 + @Override
164 + void add(Puppet puppet) {
165 + mPuppets.add(puppet)
166 + }
167 +
168 + @Override
169 + Puppet next() {
170 + return mPuppets.get(currentIndex++)
171 + }
172 +
173 + @Override
174 + void remove() {
175 +
176 + }
177 + }
178 +
179 + def static class CometTVLiveSourcesPuppet implements SourcesPuppet {
180 +
181 + def ParentPuppet mParent
182 +
183 + public CometTVLiveSourcesPuppet(ParentPuppet parent) {
184 + mParent = parent
185 + }
186 +
187 + @Override
188 + String getPublicationDate() {
189 + return null
190 + }
191 +
192 + @Override
193 + long getDuration() {
194 + return -1
195 + }
196 +
197 + @Override
198 + SourcesPuppet.SourceIterator getSources() {
199 + return new CometTVLiveSourceIterator()
200 + }
201 +
202 + @Override
203 + boolean isLive() {
204 + return true
205 + }
206 +
207 + @Override
208 + List<SourcesPuppet.SubtitleDescription> getSubtitles() {
209 + return null
210 + }
211 +
212 + @Override
213 + String getName() {
214 + return "Comet TV Live"
215 + }
216 +
217 + @Override
218 + String getCategory() {
219 + return null
220 + }
221 +
222 + @Override
223 + String getShortDescription() {
224 + return null
225 + }
226 +
227 + @Override
228 + String getImageUrl() {
229 + return "http://static-33.sinclairstoryline.com/resources/media/00cae24d-0f3f-4ae6-bc22-bc78f31fbb99-large16x9_COMET_LOGO_GREEN.jpg"
230 + }
231 +
232 + @Override
233 + String getBackgroundImageUrl() {
234 + return "http://static-12.sinclairstoryline.com/resources/media/00cae24d-0f3f-4ae6-bc22-bc78f31fbb99-large16x9_COMET_LOGO_GREEN.jpg"
235 + }
236 +
237 + @Override
238 + boolean isUnavailableIn(String region) {
239 + return false
240 + }
241 +
242 + @Override
243 + String getPreferredRegion() {
244 + return null
245 + }
246 +
247 + @Override
248 + int getShieldLevel() {
249 + return 0
250 + }
251 +
252 + @Override
253 + ParentPuppet getParent() {
254 + return mParent
255 + }
256 +
257 + @Override
258 + PuppetIterator getRelated() {
259 + return null
260 + }
261 +
262 + @Override
263 + public String toString() {
264 + return mParent == null ? getName() : mParent.toString() + " < " + getName()
265 + }
266 +
267 + def class CometTVLiveSourceIterator implements SourcesPuppet.SourceIterator {
268 +
269 + def String mSourceUrl
270 +
271 + @Override
272 + boolean hasNext() {
273 + if (mSourceUrl == null) {
274 + String html = new URL("http://www.comettv.com/watch-live/").getText(requestProperties: ['User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11'])
275 + Matcher matcher = html =~ /file: "(.+?)"/
276 + if (matcher.find()) {
277 + mSourceUrl = matcher.group(1)
278 + }
279 + return true
280 + }
281 + return false
282 + }
283 +
284 + @Override
285 + SourceDescription next() {
286 + SourceDescription sourceDescription = new SourceDescription()
287 + sourceDescription.url = mSourceUrl
288 + return sourceDescription
289 + }
290 +
291 + @Override
292 + void remove() {
293 +
294 + }
295 + }
296 + }
297 +}
...\ No newline at end of file ...\ No newline at end of file