How to use endelement method in wpt

Best JavaScript code snippet using wpt

XMLGenerator.js

Source:XMLGenerator.js Github

copy

Full Screen

1var xml = require('xml');2var logger = require('./logger');3var atvSettings = require('./settings.js');4function generatePlayXML(options) {5 var XMLWriter = require('xml-writer');6 xw = new XMLWriter;7 xw.startDocument(version='1.0', encoding='UTF-8');8 xw.startElement('atv')9 .startElement('body')10 .startElement('videoPlayer')11 .writeAttribute('id', 'com.sample.video-player')12 .startElement('httpFileVideoAsset')13 .writeAttribute('id', options.title)14 .writeElement('mediaURL', options.url)15 .writeElement('title', options.title)16 .writeElement('description', options.desc)17 .writeElement('image', options.image)18 .writeElement('upNextPresentationTime', '5')19 .writeElement('upNextPresentationDuration', '20')20 .startElement('videoPlayerSettings')21 .writeElement('subtitleSize', (options.subtitleSize || '100'))22 .endElement()23 .startElement('myMetadata')24 .writeElement('subtitleURL', 'http://trailers.apple.com/subtitle.json?url=' + options.subtitle)25 .writeElement('traktToken', options.traktToken)26 .endElement()27 .endElement()28 .endElement()29 .endElement()30 .endElement();31 xw.endDocument();32 logger.Debug(xw.toString());33 return xw.toString();34}35function generateProgressXML(moviePosterURL) {36 var XMLWriter = require('xml-writer');37 xw = new XMLWriter;38 xw.startDocument(version='1.0', encoding='UTF-8');39 xw.startElement('atv')40 .startElement('head')41 .startElement('script')42 .writeAttribute('src', 'http://trailers.apple.com/js/play.js')43 .endElement()44 .endElement()45 .startElement('body')46 .startElement('listWithPreview')47 .writeAttribute('id', 'id.progress.refresher')48 .writeAttribute('refreshInterval', '1')49 .writeAttribute('onRefresh', 'progressRefresh();')50 .startElement('header')51 .startElement('simpleHeader')52 .writeElement('title', 'Buffering...')53 .writeElement('subtitle', 'Please wait while your selection buffers')54 .endElement()55 .endElement()56 .startElement('preview')57 .startElement('mediaPreview')58 .writeElement('image', moviePosterURL)59 .endElement()60 .endElement()61 .startElement('menu')62 .startElement('sections')63 .startElement('menuSection')64 .startElement('items')65 .startElement('oneLineMenuItem')66 .writeAttribute('id', 'menuToChange')67 .writeElement('label', '[0%] 0.00MB - 0.00MB/s')68 .endElement()69 .endElement()70 .endElement()71 .endElement()72 .endElement()73 .endElement()74 .endElement()75 .endElement();76 xw.endDocument();77 logger.Debug(xw.toString());78 return xw.toString();79}80function errorXML(title, err, callback){81 var XMLWriter = require('xml-writer');82 xw = new XMLWriter;83 xw.startDocument(version='1.0', encoding='UTF-8');84 xw.startElement('atv')85 .startElement('body')86 .startElement('dialog')87 .writeAttribute('id', 'com.sample.error-dialog')88 .writeElement('title', title)89 .writeElement('description', err)90 .endElement()91 .endElement()92 .endElement();93 xw.endDocument();94 logger.Debug(xw.toString());95 callback(xw.toString());96}97function updateContextXML(callback)98{99 xmlstr = '<atv><body><optionList id="fakeUpdater" autoSelectSingleItem="true"> \100 <items><oneLineMenuItem id="0" onSelect="atv.unloadPage()"><label></label> \101 </oneLineMenuItem></items></optionList></body></atv>';102 callback(xmlstr);103}104function generateQuality(torrentID, UDID, qualities, subtitle, callback){105 var XMLWriter = require('xml-writer');106 xw = new XMLWriter;107 xw.startDocument(version='1.0', encoding='UTF-8');108 xw.startElement('atv')109 .startElement('head')110 .startElement('script')111 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')112 .endElement()113 .endElement()114 .startElement('body')115 .startElement('optionDialog')116 .writeAttribute('id', 'scrobble.optionDialog')117 .startElement('header')118 .startElement('simpleHeader')119 .writeElement('title', 'Select Quality')120 .writeElement('subtitle', 'Please select your desired quality')121 .endElement()122 .endElement()123 .startElement('menu')124 .startElement('sections')125 .startElement('menuSection')126 .startElement('header')127 .startElement('horizontalDivider')128 .writeAttribute('alignment', 'left')129 .writeElement('title', '')130 .endElement()131 .endElement()132 .startElement('items');133 qualities.split(",").forEach(function(quality){134 xw.startElement('oneLineMenuItem')135 .writeAttribute('id', 'item')136 .writeAttribute('onSelect', "atv.unloadPage();atv.loadAndSwapURL('http://trailers.apple.com/MoviePrePlay.xml?torrentID=" + torrentID + '&UDID=' + UDID + '&quality=' + quality + '&subtitle=' + subtitle + "');")137 .writeElement('label', quality)138 .endElement();139 })140 xw.endElement()141 .endElement()142 .endElement()143 .endElement()144 .endElement()145 .endElement()146 .endElement();147 xw.endDocument();148 logger.Debug(xw.toString());149 callback(xw.toString());150}151function generateSubtitles(imdb, torrentID, UDID, quality, callback){152 var subs = require('./SubtitleAPI');153 var langConverter = require('./lang');154 subs.searchMovie({imdbid: imdb}, 'PopcornTV').then(function(subtitles){155 logger.Debug(subtitles);156 var subtitles2 = Object.keys(subtitles).sort();157 var XMLWriter = require('xml-writer');158 xw = new XMLWriter;159 xw.startDocument(version='1.0', encoding='UTF-8');160 xw.startElement('atv')161 .startElement('head')162 .startElement('script')163 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')164 .endElement()165 .endElement()166 .startElement('body')167 .startElement('optionDialog')168 .writeAttribute('id', 'scrobble.optionDialog')169 .startElement('header')170 .startElement('simpleHeader')171 .writeElement('title', 'Select Subtitles')172 .writeElement('subtitle', 'Please select your desired language')173 .endElement()174 .endElement()175 .startElement('menu')176 .startElement('sections')177 .startElement('menuSection')178 .startElement('header')179 .startElement('horizontalDivider')180 .writeAttribute('alignment', 'left')181 .writeElement('title', '')182 .endElement()183 .endElement()184 .startElement('items')185 .startElement('oneLineMenuItem')186 .writeAttribute('id', 'item')187 .writeAttribute('onSelect', "atv.unloadPage();atv.loadAndSwapURL('http://trailers.apple.com/MoviePrePlay.xml?torrentID=" + torrentID + '&UDID=' + UDID + '&quality=' + quality + '&subtitle=' + 'Off' + "');")188 .writeElement('label', 'Off')189 .endElement();;190 subtitles2.forEach(function(lang){191 xw.startElement('oneLineMenuItem')192 .writeAttribute('id', 'item')193 .writeAttribute('onSelect', "atv.unloadPage();atv.loadAndSwapURL('http://trailers.apple.com/MoviePrePlay.xml?torrentID=" + torrentID + '&UDID=' + UDID + '&quality=' + quality + '&subtitle=' + subtitles[lang].url + "');")194 .writeElement('label', langConverter.getLanguageName(lang))195 .endElement();196 })197 xw.endElement()198 .endElement()199 .endElement()200 .endElement()201 .endElement()202 .endElement()203 .endElement();204 xw.endDocument();205 logger.Debug(xw.toString());206 callback(xw.toString());207 }).fail(function(error){208 logger.error(error);209 });210}211function generateQualityTV(imdb, season, episode, UDID, qualities, subtitle, callback){212 var XMLWriter = require('xml-writer');213 xw = new XMLWriter;214 xw.startDocument(version='1.0', encoding='UTF-8');215 xw.startElement('atv')216 .startElement('head')217 .startElement('script')218 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')219 .endElement()220 .endElement()221 .startElement('body')222 .startElement('optionDialog')223 .writeAttribute('id', 'scrobble.optionDialog')224 .startElement('header')225 .startElement('simpleHeader')226 .writeElement('title', 'Select Quality')227 .writeElement('subtitle', 'Please select your desired quality')228 .endElement()229 .endElement()230 .startElement('menu')231 .startElement('sections')232 .startElement('menuSection')233 .startElement('header')234 .startElement('horizontalDivider')235 .writeAttribute('alignment', 'left')236 .writeElement('title', '')237 .endElement()238 .endElement()239 .startElement('items');240 qualities.split(",").forEach(function(quality){241 xw.startElement('oneLineMenuItem')242 .writeAttribute('id', 'item')243 .writeAttribute('onSelect', "atv.unloadPage();atv.loadAndSwapURL('http://trailers.apple.com/TVPrePlay.xml?imdb=" + imdb + '&season=' + season + '&episode=' + episode + '&UDID=' + UDID + '&quality=' + quality + '&subtitle=' + subtitle + "');")244 .writeElement('label', quality)245 .endElement();246 })247 xw.endElement()248 .endElement()249 .endElement()250 .endElement()251 .endElement()252 .endElement()253 .endElement();254 xw.endDocument();255 logger.Debug(xw.toString());256 callback(xw.toString());257}258function generateSubtitlesTV(imdb, UDID, quality, episode, season, callback){259 var subs = require('./SubtitleAPI');260 var langConverter = require('./lang');261 subs.searchMovie({imdbid: imdb, episode: episode, season: season}, 'PopcornTV').then(function(subtitles){262 var subtitles2 = Object.keys(subtitles).sort();263 var XMLWriter = require('xml-writer');264 xw = new XMLWriter;265 xw.startDocument(version='1.0', encoding='UTF-8');266 xw.startElement('atv')267 .startElement('head')268 .startElement('script')269 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')270 .endElement()271 .endElement()272 .startElement('body')273 .startElement('optionDialog')274 .writeAttribute('id', 'scrobble.optionDialog')275 .startElement('header')276 .startElement('simpleHeader')277 .writeElement('title', 'Select Subtitles')278 .writeElement('subtitle', 'Please select your desired language')279 .endElement()280 .endElement()281 .startElement('menu')282 .startElement('sections')283 .startElement('menuSection')284 .startElement('header')285 .startElement('horizontalDivider')286 .writeAttribute('alignment', 'left')287 .writeElement('title', '')288 .endElement()289 .endElement()290 .startElement('items')291 .startElement('oneLineMenuItem')292 .writeAttribute('id', 'item')293 .writeAttribute('onSelect', "atv.unloadPage();atv.loadAndSwapURL('http://trailers.apple.com/TVPrePlay.xml?imdb=" + imdb + '&season=' + season + '&episode=' + episode + '&UDID=' + UDID + '&quality=' + quality + '&subtitle=' + 'Off' + "');")294 .writeElement('label', 'Off')295 .endElement();;296 subtitles2.forEach(function(lang){297 xw.startElement('oneLineMenuItem')298 .writeAttribute('id', 'item')299 .writeAttribute('onSelect', "atv.unloadPage();atv.loadAndSwapURL('http://trailers.apple.com/TVPrePlay.xml?imdb=" + imdb + '&season=' + season + '&episode=' + episode + '&UDID=' + UDID + '&quality=' + quality + '&subtitle=' + subtitles[lang].url + "');")300 .writeElement('label', langConverter.getLanguageName(lang))301 .endElement();302 })303 xw.endElement()304 .endElement()305 .endElement()306 .endElement()307 .endElement()308 .endElement()309 .endElement();310 xw.endDocument();311 logger.Debug(xw.toString());312 callback(xw.toString());313 }).fail(function(error){314 logger.error(error);315 });316}317function generateSettingsXML(UDID, commit, callback){318 var settings = atvSettings.loadSettings(UDID);319 logger.Debug(settings);320 var XMLWriter = require('xml-writer');321 xw = new XMLWriter;322 xw.startDocument(version='1.0', encoding='UTF-8');323 xw.startElement('atv')324 .startElement('head')325 .startElement('script')326 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')327 .endElement()328 .startElement('script')329 .writeAttribute('src', 'http://trailers.apple.com/js/settings.js')330 .endElement()331 .endElement()332 .startElement('body')333 .startElement('listWithPreview')334 .writeAttribute('id', 'SettingsPage')335 .startElement('header')336 .startElement('simpleHeader')337 .writeElement('title', 'Settings')338 .endElement()339 .endElement()340 .startElement('preview')341 .startElement('keyedPreview')342 .writeElement('title', 'About')343 .writeElement('summary', '')344 .startElement('metadataKeys')345 .writeElement('label', 'About')346 .writeElement('label', 'Commit')347 .writeElement('label', 'Authors')348 .writeElement('label', 'Homepage')349 .writeElement('label', 'Forum')350 .endElement()351 .startElement('metadataValues')352 .writeElement('label', 'Description')353 .writeElement('label', commit)354 .writeElement('label', 'Developer Name')355 .writeElement('label', 'Website')356 .writeElement('label', 'Forum Thread')357 .endElement()358 .writeElement('image', 'http://trailers.apple.com/thumbnails/Logo.png')359 .endElement()360 .endElement()361 .startElement('menu')362 .startElement('sections')363 .startElement('menuSection')364 .startElement('header')365 .startElement('horizontalDivider')366 .writeAttribute('alignment', 'left')367 .writeElement('title', '')368 .endElement()369 .endElement()370 .startElement('items')371 .startElement('oneLineMenuItem')372 .writeAttribute('id', 'quality')373 .writeAttribute('onSelect', "toggleSetting('quality', '" + (settings.quality || "720p") + "')")374 .writeElement('label', 'Prefered Movie Quality')375 .writeElement('rightLabel', (settings.quality || "720p"))376 .endElement()377 .startElement('oneLineMenuItem')378 .writeAttribute('id', 'tvquality')379 .writeAttribute('onSelect', "toggleSetting('tvquality', '" + (settings.tvquality || "480p") + "')")380 .writeElement('label', 'Prefered TV Show Quality')381 .writeElement('rightLabel', (settings.tvquality || "480p"))382 .endElement()383 .startElement('oneLineMenuItem')384 .writeAttribute('id', 'fanart')385 .writeAttribute('onSelect', "toggleSetting('fanart', '" + (settings.fanart || 'On') + "')")386 .writeElement('label', 'Fanart')387 .writeElement('rightLabel', (settings.fanart || 'On'))388 .endElement()389 .startElement('oneLineMenuItem')390 .writeAttribute('id', 'keep')391 .writeAttribute('onSelect', "toggleSetting('keep', '" + (settings.keep || 'On') + "')")392 .writeElement('label', 'Keep Video Downloads')393 .writeElement('rightLabel', (settings.keep || 'On'))394 .endElement()395 .endElement()396 .endElement()397 .startElement('menuSection')398 .startElement('header')399 .startElement('horizontalDivider')400 .writeAttribute('alignment', 'left')401 .writeElement('title', 'Subtitles')402 .endElement()403 .endElement()404 .startElement('items')405 .startElement('oneLineMenuItem')406 .writeAttribute('id', 'subSize')407 .writeAttribute('onSelect', "toggleSetting('subSize', '" + (settings.subSize || '100') + "')")408 .writeElement('label', 'Subtitle Size')409 .writeElement('rightLabel', settings.subSize || '100')410 .endElement()411 .startElement('oneLineMenuItem')412 .writeAttribute('id', 'subtitle')413 .writeAttribute('onSelect', "toggleSetting('subtitle', '" + (settings.subtitle || 'Off') + "')")414 .writeElement('label', 'Default Subtitle Language')415 .writeElement('rightLabel', settings.subtitle || 'Off')416 .endElement()417 .endElement()418 .endElement();419 xw.endDocument();420 callback(xw.toString());421}422function generateMoviesXML(title, sort_by, callback){423 var XMLWriter = require('xml-writer');424 xw = new XMLWriter;425 xw.startDocument(version='1.0', encoding='UTF-8');426 xw.startElement('atv')427 .startElement('head')428 .startElement('script')429 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')430 .endElement()431 .endElement()432 .startElement('body')433 .startElement('scroller').writeAttribute('id', 'com.sample.movie-grid')434 .startElement('header')435 .startElement('simpleHeader')436 .writeElement('title', title)437 .endElement()438 .endElement()439 .startElement('items')440 .startElement('grid')441 .writeAttribute('columnCount', '7').writeAttribute('id', 'grid_0')442 .startElement('items')443 .writeAttribute('id', 'items');444 var API = require('./MoviesAPI');445 var movies = API.getMovies("1", sort_by, "50", function(movies){446 for(var i = 0; i <= movies.length-1; i++)447 {448 var url = "http://trailers.apple.com/Movies/MoviePrePlay.xml?torrentID=" + movies[i].id + '&imdb=' + movies[i].imdb_code;449 xw.startElement('moviePoster')450 .writeAttribute('id', movies[i].title.replace(/\s/g, ''))451 .writeAttribute('alwaysShowTitles', 'true')452 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')453 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')454 .writeAttribute('onHoldSelect', 'scrobbleMenu("http://trailers.apple.com/scrobble.xml?type=movie&id=' + movies[i].id + '")')455 .writeElement('title', movies[i].title)456 .writeElement('subtitle', movies[i].year)457 .writeElement('image', movies[i].medium_cover_image)458 .writeElement('defaultImage', 'http://trailers.apple.com/thumbnails/movie-large.png')459 .endElement();460 }461 xw.startElement('moviePoster')462 .writeAttribute('id', "50")463 .writeAttribute('alwaysShowTitles', 'true')464 .writeAttribute('onPlay', 'loadMore("movie", "' + sort_by + '", "2")')465 .writeAttribute('onSelect', 'loadMore("movie", "' + sort_by + '", "2")')466 .writeElement('title', 'View More')467 .writeElement('subtitle', '')468 .writeElement('image', 'http://trailers.apple.com/thumbnails/view-more.png')469 .writeElement('defaultImage', 'resource://Poster.png')470 .endElement();471 xw.endDocument();472 logger.Debug(xw.toString());473 callback(xw.toString());474 });475}476function generateScrobbleXML(type, id, UDID, url, label, callback){477 var XMLWriter = require('xml-writer');478 xw = new XMLWriter;479 xw.startDocument(version='1.0', encoding='UTF-8');480 xw.startElement('atv')481 .startElement('body')482 .startElement('popUpMenu')483 .writeAttribute('id', 'context_menu')484 .startElement('sections')485 .startElement('menuSection')486 .startElement('items')487 .startElement('oneLineMenuItem')488 .writeAttribute('id', 'item2')489 .writeAttribute('onSelect', "atv.loadURL('http://trailers.apple.com/" + url + "?type=" + type + '&id=' + id + '&UDID=' + UDID + "')")490 .writeElement('label', label)491 .endElement()492 .endElement()493 .endElement()494 .endElement()495 .endElement()496 .endElement()497 .endElement();498 xw.endDocument();499 logger.Debug(xw.toString());500 callback(xw.toString());501}502function generateScrobbleXMLOLD(type, id, UDID, url, label, callback){503 var XMLWriter = require('xml-writer');504 xw = new XMLWriter;505 xw.startDocument(version='1.0', encoding='UTF-8');506 xw.startElement('atv')507 .startElement('head')508 .startElement('script')509 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')510 .endElement()511 .endElement()512 .startElement('body')513 .startElement('optionDialog')514 .writeAttribute('id', 'scrobble.optionDialog')515 .startElement('header')516 .startElement('simpleHeader')517 .writeElement('title', 'Favorites')518 .writeElement('subtitle', 'Add or remove movie from your Favorites.')519 .endElement()520 .endElement()521 .startElement('menu')522 .startElement('sections')523 .startElement('menuSection')524 .startElement('header')525 .startElement('horizontalDivider')526 .writeAttribute('alignment', 'left')527 .writeElement('title', '')528 .endElement()529 .endElement()530 .startElement('items')531 .startElement('oneLineMenuItem')532 .writeAttribute('id', 'item')533 .writeAttribute('onSelect', "loadURL('http://trailers.apple.com/" + url + "?type=" + type + '&id=' + id + '&UDID=' + UDID + "');atv.unloadPage();")534 .writeElement('label', label)535 .endElement()536 xw.endElement()537 .endElement()538 .endElement()539 .endElement()540 .endElement()541 .endElement()542 .endElement();543 xw.endDocument();544 logger.Debug(xw.toString());545 callback(xw.toString());546}547function generateMovieParadeXML(sort_by, callback){548 var XMLWriter = require('xml-writer');549 xw = new XMLWriter;550 xw.startDocument(version='1.0', encoding='UTF-8');551 xw.startElement('atv')552 .startElement('body')553 .startElement('preview')554 .startElement('paradePreview').writeAttribute('inOrder', 'true')555 var API = require('./MoviesAPI');556 var movies = API.getMovies("1", sort_by, "15", function(movies){557 for(var i = 0; i <= movies.length-1; i++)558 {559 xw.writeElement('image', movies[i].medium_cover_image)560 }561 xw.endDocument();562 logger.Debug(xw.toString());563 callback(xw.toString());564 });565}566function generateTVParadeXML(sort_by, callback){567 var XMLWriter = require('xml-writer');568 xw = new XMLWriter;569 xw.startDocument(version='1.0', encoding='UTF-8');570 xw.startElement('atv')571 .startElement('body')572 .startElement('preview')573 .startElement('paradePreview').writeAttribute('inOrder', 'true')574 var API = require('./TVApi');575 var tv = API.getTV(1, sort_by, "15", function(shows){576 for(var i = 0; i <= shows.length-1; i++)577 {578 xw.writeElement('image', shows[i].images.poster)579 }580 xw.endDocument();581 logger.Debug(xw.toString());582 callback(xw.toString());583 });584}585function generateGenre(genre, type, callback){586 var XMLWriter = require('xml-writer');587 xw = new XMLWriter;588 xw.startDocument(version='1.0', encoding='UTF-8');589 xw.startElement('atv')590 .startElement('head')591 .startElement('script')592 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')593 .endElement()594 .endElement()595 .startElement('body')596 .startElement('preview')597 .startElement('scrollerPreview').writeAttribute('id', 'com.sample.scrollerPreview')598 .startElement('items')599 .startElement('grid')600 .writeAttribute('id', 'grid_1')601 .writeAttribute('columnCount', '5')602 .startElement('items');603 if (type == 'movie'){604 var API = require('./MoviesAPI');605 var movies = API.getMoviesGenre(genre, "50", function(movies){606 for(var i = 0; i <= movies.length-1; i++)607 {608 var url = "http://trailers.apple.com/Movies/MoviePrePlay.xml?torrentID=" + movies[i].id;609 xw.startElement('moviePoster')610 .writeAttribute('id', movies[i].title.replace(/\s/g, ''))611 .writeAttribute('alwaysShowTitles', 'true')612 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')613 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')614 .writeAttribute('onHoldSelect', 'scrobbleMenu("http://trailers.apple.com/scrobble.xml?type=movie&id=' + movies[i].id + '")')615 .writeElement('title', movies[i].title)616 .writeElement('subtitle', movies[i].year)617 .writeElement('image', movies[i].medium_cover_image)618 .writeElement('defaultImage', 'resource://Poster.png')619 .endElement();620 }621 xw.endDocument();622 logger.Debug(xw.toString());623 callback(xw.toString());624 });625 } else if (type == 'tv'){626 var API = require('./TVApi');627 API.getGenre(genre, function(shows){628 for(var i = 0; i <= shows.length-1; i++)629 {630 var url = 'http://trailers.apple.com/seasons.xml?imdb=' + shows[i].imdb_id + '&title=' + shows[i].title.replace(/ /g,"%20");631 xw.startElement('moviePoster')632 .writeAttribute('id', shows[i].title.replace(/\s/g, ''))633 .writeAttribute('alwaysShowTitles', 'true')634 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')635 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')636 .writeAttribute('onHoldSelect', "scrobbleMenu('http://trailers.apple.com/scrobble.xml?type=tv&id=" + shows[i].imdb_id + "')")637 .writeElement('title', shows[i].title)638 .writeElement('subtitle', shows[i].year + ' | ' + shows[i].num_seasons + ' Seasons')639 .writeElement('image', shows[i].images.poster)640 .writeElement('defaultImage', 'resource://Poster.png')641 .endElement();642 }643 xw.endDocument();644 logger.Debug(xw.toString());645 callback(xw.toString());646 });647 }648}649function generateMovieExtras(query, callback){650 var XMLWriter = require('xml-writer');651 xw = new XMLWriter;652 xw.startDocument(version='1.0', encoding='UTF-8');653 xw.startElement('atv')654 .startElement('head')655 .startElement('script')656 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')657 .endElement()658 .endElement()659 .startElement('body')660 .startElement('preview')661 .startElement('scrollerPreview').writeAttribute('id', 'com.sample.scrollerPreview')662 .startElement('items')663 .startElement('grid')664 .writeAttribute('id', 'grid_1')665 .writeAttribute('columnCount', '5')666 .startElement('items')667 var API = require('./MoviesAPI');668 var movies = API.searchMovies(query, function(movies){669 for(var i = 0; i <= movies.length-1; i++)670 {671 var url = "http://trailers.apple.com/Movies/MoviePrePlay.xml?torrentID=" + movies[i].id;672 xw.startElement('moviePoster')673 .writeAttribute('id', movies[i].title.replace(/\s/g, ''))674 .writeAttribute('alwaysShowTitles', 'true')675 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')676 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')677 .writeAttribute('onHoldSelect', 'scrobbleMenu("http://trailers.apple.com/scrobble.xml?type=movie&id=' + movies[i].id + '")')678 .writeElement('title', movies[i].title)679 .writeElement('subtitle', movies[i].year)680 .writeElement('image', movies[i].medium_cover_image)681 .writeElement('defaultImage', 'resource://Poster.png')682 .endElement();683 }684 xw.endDocument();685 logger.Debug(xw.toString());686 callback(xw.toString());687 });688}689function generateSearchResults(query, callback){690 var XMLWriter = require('xml-writer');691 xw = new XMLWriter;692 xw.startDocument(version='1.0', encoding='UTF-8');693 xw.startElement('atv')694 .startElement('head')695 .startElement('script')696 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')697 .endElement()698 .endElement()699 .startElement('body')700 .startElement('searchResults').writeAttribute('id', 'searchResults')701 .startElement('menu')702 .startElement('sections');703 var API = require('./MoviesAPI');704 var movies = API.searchMovies(query, function(movies){705 if (movies.length > 0){706 xw.startElement('menuSection')707 .startElement('header')708 .startElement('horizontalDivider')709 .writeAttribute('alignment', 'left')710 .writeElement('title', 'Movies')711 .endElement()712 .endElement()713 .startElement('items')714 }715 for(var i = 0; i <= movies.length-1; i++)716 {717 var url = "http://trailers.apple.com/Movies/MoviePrePlay.xml?torrentID=" + movies[i].id;718 xw.startElement('twoLineEnhancedMenuItem')719 .writeAttribute('id', movies[i].title.replace(/\s/g, ''))720 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')721 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')722 .writeAttribute('onHoldSelect', 'oldScrobbleMenu("http://trailers.apple.com/scrobble.xml?type=movie&id=' + movies[i].id + '")')723 .writeElement('label', movies[i].title)724 .writeElement('image', movies[i].small_cover_image)725 .writeElement('defaultImage', 'resource://Poster.png')726 .endElement();727 }728 if (movies.length > 0){729 xw.endElement()730 .endElement();731 }732 var API = require('./TVApi');733 var search = API.searchShows(query, function(shows){734 if (shows.length > 0){735 xw.startElement('menuSection')736 .startElement('header')737 .startElement('horizontalDivider')738 .writeAttribute('alignment', 'left')739 .writeElement('title', 'TV Shows')740 .endElement()741 .endElement()742 .startElement('items');743 }744 for(var i = 0; i <= shows.length-1; i++)745 {746 var url = 'http://trailers.apple.com/seasons.xml?imdb=' + shows[i].imdb_id + '&title=' + shows[i].title.replace(/ /g,"%20");747 xw.startElement('twoLineEnhancedMenuItem')748 .writeAttribute('id', shows[i].title.replace(/\s/g, ''))749 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')750 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')751 .writeAttribute('onHoldSelect', "oldScrobbleMenu('http://trailers.apple.com/scrobble.xml?type=tv&id=" + shows[i].imdb_id + "')")752 .writeElement('label', shows[i].title)753 .writeElement('image', shows[i].images.poster)754 .writeElement('defaultImage', 'resource://Poster.png')755 .endElement();756 }757 xw.endDocument();758 logger.Debug(xw.toString());759 callback(xw.toString());760 });761 });762}763function generateMovieSearchResults(query, callback){764 var XMLWriter = require('xml-writer');765 xw = new XMLWriter;766 xw.startDocument(version='1.0', encoding='UTF-8');767 xw.startElement('atv')768 .startElement('head')769 .startElement('script')770 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')771 .endElement()772 .endElement()773 .startElement('body')774 .startElement('searchResults').writeAttribute('id', 'searchResults')775 .startElement('menu')776 .startElement('sections')777 .startElement('menuSection')778 .startElement('header')779 .startElement('horizontalDivider')780 .writeAttribute('alignment', 'left')781 .writeElement('title', 'Movies')782 .endElement()783 .endElement()784 .startElement('items')785 var API = require('./MoviesAPI');786 var movies = API.searchMovies(query, function(movies){787 for(var i = 0; i <= movies.length-1; i++)788 {789 var url = "http://trailers.apple.com/Movies/MoviePrePlay.xml?torrentID=" + movies[i].id;790 xw.startElement('twoLineEnhancedMenuItem')791 .writeAttribute('id', movies[i].title.replace(/\s/g, ''))792 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')793 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')794 .writeAttribute('onHoldSelect', 'oldScrobbleMenu("http://trailers.apple.com/scrobble.xml?type=movie&id=' + movies[i].id + '")')795 .writeElement('label', movies[i].title)796 .writeElement('image', movies[i].small_cover_image)797 .writeElement('defaultImage', 'resource://Poster.png')798 .endElement();799 }800 xw.endDocument();801 logger.Debug(xw.toString());802 callback(xw.toString());803 });804}805function generateTVSearchResults(query, callback){806 var XMLWriter = require('xml-writer');807 xw = new XMLWriter;808 xw.startDocument(version='1.0', encoding='UTF-8');809 xw.startElement('atv')810 .startElement('head')811 .startElement('script')812 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')813 .endElement()814 .endElement()815 .startElement('body')816 .startElement('searchResults').writeAttribute('id', 'searchResults')817 .startElement('menu')818 .startElement('sections')819 .startElement('menuSection')820 .startElement('header')821 .startElement('horizontalDivider')822 .writeAttribute('alignment', 'left')823 .writeElement('title', 'TV Shows')824 .endElement()825 .endElement()826 .startElement('items')827 var API = require('./TVApi');828 var search = API.searchShows(query, function(shows){829 for(var i = 0; i <= shows.length-1; i++)830 {831 var url = 'http://trailers.apple.com/seasons.xml?imdb=' + shows[i].imdb_id + '&title=' + shows[i].title.replace(/ /g,"%20");832 xw.startElement('twoLineEnhancedMenuItem')833 .writeAttribute('id', shows[i].title.replace(/\s/g, ''))834 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')835 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')836 .writeAttribute('onHoldSelect', "oldScrobbleMenu('http://trailers.apple.com/scrobble.xml?type=tv&id=" + shows[i].imdb_id + "')")837 .writeElement('label', shows[i].title)838 .writeElement('image', shows[i].images.poster)839 .writeElement('defaultImage', 'resource://Poster.png')840 .endElement();841 }842 xw.endDocument();843 logger.Debug(xw.toString());844 callback(xw.toString());845 });846}847function generateMoviePrePlayFanartXML(torrentID, UDID, atvRes, quality, subtitle, callback){848 var API = require('./MoviesAPI');849 var inset = '690';850 if (atvRes == '720'){851 inset = '460';852 }853 var movies = API.getMovieWithFanart(torrentID, atvRes, function(movie, fanart){854 var XMLWriter = require('xml-writer');855 var url = "http://trailers.apple.com/Movies/MoviePrePlay.xml?torrentID=" + movie.id + '&UDID=' + UDID;856 xw = new XMLWriter;857 xw.startDocument(version='1.0', encoding='UTF-8');858 xw.startElement('atv')859 .startElement('head')860 .startElement('script')861 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')862 .endElement()863 .endElement()864 .startElement('body')865 .startElement('itemDetailWithImageHeader')866 .writeAttribute('id', 'com.apple.trailer')867 .writeAttribute('layout', 'compact')868 .startElement('styles')869 .startElement('color')870 .writeAttribute('name', 'titleColor')871 .text('#fafafa')872 .endElement()873 .startElement('color')874 .writeAttribute('name', 'metadataColor')875 .text('#fafafa')876 .endElement()877 .endElement()878 .startElement('header')879 .startElement('imageHeader')880 .startElement('image')881 .writeAttribute('insets', '0, 0, ' + inset + ', 0')882 .writeAttribute('required', 'true')883 .text('http://trailers.apple.com/' + fanart)884 .endElement()885 .endElement()886 .endElement()887 .writeElement('title', movie.title)888 .writeElement('footnote', movie.year)889 .writeElement('rating', movie.mpa_rating)890 .writeElement('summary', movie.description_full)891 .startElement('userRatings')892 .startElement('starRating')893 .writeElement('percentage', movie.rt_audience_score)894 .endElement()895 .endElement()896 .startElement('image')897 .writeAttribute('style', 'moviePoster')898 .text(movie.images.large_cover_image)899 .endElement()900 .writeElement('defaultImage', 'resource://Poster.png')901 .startElement('table')902 .startElement('columnDefinitions')903 .startElement('columnDefinition')904 .writeAttribute('alignment', 'left')905 .writeAttribute('width', '50')906 .writeElement('title', 'Details')907 .endElement()908 .endElement()909 .startElement('rows')910 .startElement('row')911 .writeElement('label', parseGenre(movie.genres))912 .endElement()913 .startElement('row')914 .writeElement('label', parseTime(movie.runtime))915 .endElement()916 .startElement('row')917 .startElement('mediaBadges')918 .startElement('additionalMediaBadges');919 var num = 0;920 movie.torrents.forEach(function(torrent){921 xw.startElement('urlBadge')922 .writeAttribute('insertIndex', num)923 .writeAttribute('required', 'true')924 .writeAttribute('src', 'http://trailers.apple.com/thumbnails/MediaBadges/' + torrent.quality + '.png')925 .endElement();926 num += 1;927 xw.startElement('urlBadge')928 .writeAttribute('insertIndex', num)929 .writeAttribute('required', 'true')930 .writeAttribute('src', 'http://trailers.apple.com/thumbnails/MediaBadges/' + torrentHealth(torrent) + '.png')931 .endElement();932 num += 1;933 })934 xw.endElement()935 .endElement()936 .endElement()937 .endElement()938 .endElement()939 .startElement('centerShelf')940 .startElement('shelf')941 .writeAttribute('id', 'centerShelf')942 .writeAttribute('columnCount', '4')943 .writeAttribute('center', 'true')944 .startElement('sections')945 .startElement('shelfSection')946 .startElement('items')947 .startElement('actionButton')948 .writeAttribute('id', 'play')949 .writeAttribute('onSelect', "addUDIDtoQuery('http://trailers.apple.com/Movies/MoviePlay.xml?torrent=" + selectTorrent(movie.torrents, quality) + "&id=" + torrentID + "&title=" + encodeURIComponent(movie.title.replace(/'/g, '')) + "&desc=" + encodeURIComponent(movie.description_full.replace(/'/g, '')) + "&poster=" + movie.images.large_cover_image + '&subtitle=' + subtitle + "')")950 .writeElement('title', 'Play')951 .writeElement('image', 'resource://Play.png')952 .writeElement('focusedImage', 'resource://PlayFocused.png')953 .endElement()954 .startElement('actionButton')955 .writeAttribute('id', 'trailer')956 .writeAttribute('onSelect', "addUDIDtoQuery('http://trailers.apple.com/Movies/MoviePlay.xml?torrent=https://www.youtube.com/watch?v=" + movie.yt_trailer_code + "&id=" + torrentID + "yt&poster=http://www.youtube.com/yt/brand/media/image/YouTube-logo-full_color.png')")957 .writeElement('title', 'Trailer')958 .writeElement('image', 'resource://Preview.png')959 .writeElement('focusedImage', 'resource://PreviewFocused.png')960 .endElement()961 .startElement('actionButton')962 .writeAttribute('id', 'select')963 .writeAttribute('onSelect', "atv.loadURL('http://trailers.apple.com/quality.xml?torrentID=" + torrentID + '&UDID=' + UDID + '&qualities=' + getQualities(movie.torrents) + '&subtitle=' + subtitle + "')")964 .writeElement('title', 'Select Quality')965 .writeElement('image', 'resource://Queue.png')966 .writeElement('focusedImage', 'resource://QueueFocused.png')967 .endElement()968 .startElement('actionButton')969 .writeAttribute('id', 'subtitle')970 .writeAttribute('onSelect', "atv.loadURL('http://trailers.apple.com/subtitles.xml?imdb=" + movie.imdb_code + "&torrentID=" + torrentID + '&UDID=' + UDID + '&quality=' + quality + "')")971 .writeElement('title', 'Subtitles')972 .writeElement('image', 'resource://Queue.png')973 .writeElement('focusedImage', 'resource://QueueFocused.png')974 .endElement()975 .endElement()976 .endElement()977 .endElement()978 .endElement()979 .endElement()980 .startElement('divider')981 .startElement('smallCollectionDivider')982 .writeAttribute('alignment', 'left')983 .writeElement('title', 'Related Movies')984 .endElement()985 .endElement()986 .startElement('bottomShelf')987 .startElement('shelf')988 .writeAttribute('columnCount', '7')989 .writeAttribute('id', 'bottomShelf')990 .startElement('sections')991 .startElement('shelfSection')992 .startElement('items');993 var API = require('./MoviesAPI');994 var movies = API.getRelatedMovies(torrentID, function(movies){995 for(var i = 0; i <= movies.length-1; i++)996 {997 var url = "http://trailers.apple.com/Movies/MoviePrePlay.xml?torrentID=" + movies[i].id;998 xw.startElement('moviePoster')999 .writeAttribute('id', movies[i].title.replace(/\s/g, ''))1000 .writeAttribute('alwaysShowTitles', 'true')1001 .writeAttribute('related', 'true')1002 .writeAttribute('onSelect', "addUDIDtoQuery('" + url + "')")1003 .writeAttribute('onHoldSelect', 'scrobbleMenu("http://trailers.apple.com/scrobble.xml?type=movie&id=' + movies[i].id + '")')1004 .writeElement('title', movies[i].title)1005 .writeElement('subtitle', movies[i].year)1006 .writeElement('image', movies[i].medium_cover_image)1007 .writeElement('defaultImage', 'resource://Poster.png')1008 .endElement();1009 }1010 xw.endElement()1011 .endElement()1012 .endElement()1013 .endElement()1014 .endElement()1015 .startElement('moreInfo')1016 .startElement('listScrollerSplit')1017 .writeAttribute('id', 'com.sample.list-scroller-split')1018 .startElement('menu')1019 .startElement('sections')1020 .startElement('menuSection')1021 .startElement('header')1022 .startElement('textDivider')1023 .writeAttribute('alignment', 'left')1024 .writeAttribute('accessibilityLabel', 'Genres')1025 .writeElement('title', 'Genres')1026 .endElement()1027 .endElement()1028 .startElement('items');1029 movie.genres.forEach(function(genre){1030 xw.startElement('oneLineMenuItem')1031 .writeAttribute('id', genre)1032 .writeElement('label', genre)1033 .startElement('preview')1034 .writeElement('link', 'http://trailers.apple.com/MoviesGenreGrid.xml?genre=' + encodeURIComponent(genre))1035 .endElement()1036 .endElement();1037 })1038 xw.endElement()1039 .endElement()1040 .startElement('menuSection')1041 .startElement('header')1042 .startElement('textDivider')1043 .writeAttribute('alignment', 'left')1044 .writeAttribute('accessibilityLabel', 'Directors')1045 .writeElement('title', 'Directors')1046 .endElement()1047 .endElement()1048 .startElement('items');1049 movie.directors.forEach(function(director){1050 xw.startElement('oneLineMenuItem')1051 .writeAttribute('id', director.name)1052 .writeAttribute('accessibilityLabel', director.name)1053 .writeElement('label', director.name)1054 .writeElement('image', director.medium_image)1055 .startElement('preview')1056 .writeElement('link', 'http://trailers.apple.com/extras.xml?query=' + encodeURIComponent(director.name))1057 .endElement()1058 .endElement();1059 })1060 xw.endElement()1061 .endElement()1062 .startElement('menuSection')1063 .startElement('header')1064 .startElement('textDivider')1065 .writeAttribute('alignment', 'left')1066 .writeAttribute('accessibilityLabel', 'Actors')1067 .writeElement('title', 'Actors')1068 .endElement()1069 .endElement()1070 .startElement('items');1071 movie.actors.forEach(function(actor){1072 xw.startElement('twoLineMenuItem')1073 .writeAttribute('id', actor.name)1074 .writeAttribute('accessibilityLabel', actor.name)1075 .writeElement('label', actor.name)1076 .writeElement('label2', actor.character_name)1077 .writeElement('image', actor.medium_image)1078 .startElement('preview')1079 .writeElement('link', 'http://trailers.apple.com/extras.xml?query=' + encodeURIComponent(actor.name))1080 .endElement()1081 .endElement();1082 })1083 xw.endElement()1084 .endElement();1085 xw.endDocument();1086 logger.Debug(xw.toString());1087 callback(xw.toString());1088 });1089 });1090}1091function generateMoviePrePlayXML(torrentID, quality, subtitle, aTVversion, callback){1092 var API = require('./MoviesAPI');1093 var movies = API.getMovie(torrentID, function(movie){1094 var XMLWriter = require('xml-writer');1095 xw = new XMLWriter;1096 xw.startDocument(version='1.0', encoding='UTF-8');1097 xw.startElement('atv')1098 .startElement('head')1099 .startElement('script')1100 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')1101 .endElement()1102 .endElement()1103 .startElement('body')1104 .startElement('itemDetail').writeAttribute('id', 'com.apple.trailers')1105 .writeElement('title', movie.title)1106 .writeElement('subtitle', movie.year)1107 .writeElement('rating', movie.mpa_rating)1108 .writeElement('summary', movie.description_full)1109 .startElement('image')1110 .writeAttribute('style', 'moviePoster')1111 .text(movie.images.large_cover_image)1112 .endElement()1113 .writeElement('defaultImage', 'resource://Poster.png')1114 .startElement('table')1115 .startElement('columnDefinitions')1116 .startElement('columnDefinition')1117 .writeAttribute('alignment', 'left')1118 .writeAttribute('width', '50')1119 .writeElement('title', 'Details')1120 .endElement()1121 .endElement()1122 .startElement('rows')1123 .startElement('row')1124 .writeElement('label', parseGenre(movie.genres))1125 .endElement()1126 .startElement('row')1127 .writeElement('label', parseTime(movie.runtime))1128 .endElement();1129 if (aTVversion >= 6){1130 xw.startElement('row')1131 .startElement('mediaBadges')1132 .startElement('additionalMediaBadges');1133 var num = 0;1134 movie.torrents.forEach(function(torrent){1135 xw.startElement('urlBadge')1136 .writeAttribute('insertIndex', num)1137 .writeAttribute('required', 'true')1138 .writeAttribute('src', 'http://trailers.apple.com/thumbnails/MediaBadges/' + torrent.quality + '.png')1139 .endElement();1140 num += 1;1141 xw.startElement('urlBadge')1142 .writeAttribute('insertIndex', num)1143 .writeAttribute('required', 'true')1144 .writeAttribute('src', 'http://trailers.apple.com/thumbnails/MediaBadges/' + torrentHealth(torrent) + '.png')1145 .endElement();1146 num += 1;1147 })1148 xw.endElement()1149 .endElement()1150 .endElement();1151 }1152 xw.startElement('row')1153 .startElement('starRating')1154 .writeElement('percentage', movie.rt_audience_score)1155 .endElement()1156 .endElement()1157 .endElement()1158 .endElement()1159 .startElement('centerShelf')1160 .startElement('shelf')1161 .writeAttribute('id', 'centerShelf')1162 .writeAttribute('columnCount', '4')1163 .writeAttribute('center', 'true')1164 .startElement('sections')1165 .startElement('shelfSection')1166 .startElement('items')1167 .startElement('actionButton')1168 .writeAttribute('id', 'play')1169 .writeAttribute('onSelect', "addUDIDtoQuery('http://trailers.apple.com/Movies/MoviePlay.xml?torrent=" + selectTorrent(movie.torrents, quality) + "&id=" + torrentID + "&title=" + encodeURIComponent(movie.title.replace(/'/g, '')) + "&desc=" + encodeURIComponent(movie.description_full.replace(/'/g, '')) + "&poster=" + movie.images.large_cover_image + '&subtitle=' + subtitle + "')")1170 .writeElement('title', 'Play')1171 .writeElement('image', 'resource://Play.png')1172 .writeElement('focusedImage', 'resource://PlayFocused.png')1173 .endElement()1174 .startElement('actionButton')1175 .writeAttribute('id', 'trailer')1176 .writeAttribute('onSelect', "addUDIDtoQuery('http://trailers.apple.com/Movies/MoviePlay.xml?torrent=https://www.youtube.com/watch?v=" + movie.yt_trailer_code + "&id=" + torrentID + "yt')")1177 .writeElement('title', 'Trailer')1178 .writeElement('image', 'resource://Preview.png')1179 .writeElement('focusedImage', 'resource://PreviewFocused.png')1180 .endElement()1181 .startElement('actionButton')1182 .writeAttribute('id', 'select')1183 .writeAttribute('onSelect', "addUDIDtoQuery('http://trailers.apple.com/quality.xml?torrentID=" + torrentID + '&qualities=' + getQualities(movie.torrents) + '&subtitle=' + subtitle + "')")1184 .writeElement('title', 'Select Quality')1185 .writeElement('image', 'resource://Queue.png')1186 .writeElement('focusedImage', 'resource://QueueFocused.png')1187 .endElement()1188 .startElement('actionButton')1189 .writeAttribute('id', 'subtitle')1190 .writeAttribute('onSelect', "addUDIDtoQuery('http://trailers.apple.com/subtitles.xml?imdb=" + movie.imdb_code + "&torrentID=" + torrentID + '&quality=' + quality + "')")1191 .writeElement('title', 'Subtitles')1192 .writeElement('image', 'resource://Queue.png')1193 .writeElement('focusedImage', 'resource://QueueFocused.png')1194 .endElement()1195 .endElement()1196 .endElement()1197 .endElement()1198 .endElement()1199 .endElement()1200 .startElement('divider')1201 .startElement('smallCollectionDivider')1202 .writeAttribute('alignment', 'left')1203 .writeElement('title', 'Related Movies')1204 .endElement()1205 .endElement()1206 .startElement('bottomShelf')1207 .startElement('shelf')1208 .writeAttribute('columnCount', '7')1209 .writeAttribute('id', 'bottomShelf')1210 .startElement('sections')1211 .startElement('shelfSection')1212 .startElement('items');1213 var API = require('./MoviesAPI');1214 var movies = API.getRelatedMovies(torrentID, function(movies){1215 for(var i = 0; i <= movies.length-1; i++)1216 {1217 var url = "http://trailers.apple.com/Movies/MoviePrePlay.xml?torrentID=" + movies[i].id;1218 xw.startElement('moviePoster')1219 .writeAttribute('id', movies[i].title.replace(/\s/g, ''))1220 .writeAttribute('alwaysShowTitles', 'true')1221 .writeAttribute('related', 'true')1222 .writeAttribute('onSelect', "addUDIDtoQuery('" + url + "')")1223 .writeAttribute('onHoldSelect', 'scrobbleMenu("http://trailers.apple.com/scrobble.xml?type=movie&id=' + movies[i].id + '")')1224 .writeElement('title', movies[i].title)1225 .writeElement('subtitle', movies[i].year)1226 .writeElement('image', movies[i].medium_cover_image)1227 .writeElement('defaultImage', 'resource://Poster.png')1228 .endElement();1229 }1230 xw.endElement()1231 .endElement()1232 .endElement()1233 .endElement()1234 .endElement()1235 .startElement('moreInfo')1236 .startElement('listScrollerSplit')1237 .writeAttribute('id', 'com.sample.list-scroller-split')1238 .startElement('menu')1239 .startElement('sections')1240 .startElement('menuSection')1241 .startElement('header')1242 .startElement('textDivider')1243 .writeAttribute('alignment', 'left')1244 .writeAttribute('accessibilityLabel', 'Genres')1245 .writeElement('title', 'Genres')1246 .endElement()1247 .endElement()1248 .startElement('items');1249 movie.genres.forEach(function(genre){1250 xw.startElement('oneLineMenuItem')1251 .writeAttribute('id', genre)1252 .writeElement('label', genre)1253 .startElement('preview')1254 .writeElement('link', 'http://trailers.apple.com/MoviesGenreGrid.xml?genre=' + encodeURIComponent(genre))1255 .endElement()1256 .endElement();1257 })1258 xw.endElement()1259 .endElement()1260 .startElement('menuSection')1261 .startElement('header')1262 .startElement('textDivider')1263 .writeAttribute('alignment', 'left')1264 .writeAttribute('accessibilityLabel', 'Directors')1265 .writeElement('title', 'Directors')1266 .endElement()1267 .endElement()1268 .startElement('items');1269 movie.directors.forEach(function(director){1270 xw.startElement('oneLineMenuItem')1271 .writeAttribute('id', director.name)1272 .writeAttribute('accessibilityLabel', director.name)1273 .writeElement('label', director.name)1274 .writeElement('image', director.medium_image)1275 .startElement('preview')1276 .writeElement('link', 'http://trailers.apple.com/extras.xml?query=' + encodeURIComponent(director.name))1277 .endElement()1278 .endElement();1279 })1280 xw.endElement()1281 .endElement()1282 .startElement('menuSection')1283 .startElement('header')1284 .startElement('textDivider')1285 .writeAttribute('alignment', 'left')1286 .writeAttribute('accessibilityLabel', 'Actors')1287 .writeElement('title', 'Actors')1288 .endElement()1289 .endElement()1290 .startElement('items');1291 movie.actors.forEach(function(actor){1292 xw.startElement('twoLineMenuItem')1293 .writeAttribute('id', actor.name)1294 .writeAttribute('accessibilityLabel', actor.name)1295 .writeElement('label', actor.name)1296 .writeElement('label2', actor.character_name)1297 .writeElement('image', actor.medium_image)1298 .startElement('preview')1299 .writeElement('link', 'http://trailers.apple.com/extras.xml?query=' + encodeURIComponent(actor.name))1300 .endElement()1301 .endElement();1302 })1303 xw.endElement()1304 .endElement();1305 xw.endDocument();1306 logger.Debug(xw.toString());1307 callback(xw.toString());1308 });1309 });1310}1311function generateTVXML(title, sort_by, callback){1312 var XMLWriter = require('xml-writer');1313 xw = new XMLWriter;1314 xw.startDocument(version='1.0', encoding='UTF-8');1315 xw.startElement('atv')1316 .startElement('head')1317 .startElement('script')1318 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')1319 .endElement()1320 .endElement()1321 .startElement('body')1322 .startElement('scroller').writeAttribute('id', 'com.sample.movie-grid')1323 .startElement('header')1324 .startElement('simpleHeader')1325 .writeElement('title', title)1326 .endElement()1327 .endElement()1328 .startElement('items')1329 .startElement('grid')1330 .writeAttribute('columnCount', '7').writeAttribute('id', 'grid_0')1331 .startElement('items')1332 .writeAttribute('id', 'items');1333 var API = require('./TVApi');1334 var tv = API.getTV(1, sort_by, "50", function(shows){1335 for(var i = 0; i <= shows.length-1; i++)1336 {1337 var url = 'http://trailers.apple.com/seasons.xml?imdb=' + shows[i].imdb_id + '&title=' + shows[i].title.replace(/ /g,"%20");1338 xw.startElement('moviePoster')1339 .writeAttribute('id', shows[i].title.replace(/\s/g, ''))1340 .writeAttribute('alwaysShowTitles', 'true')1341 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')1342 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')1343 .writeAttribute('onHoldSelect', "scrobbleMenu('http://trailers.apple.com/scrobble.xml?type=tv&id=" + shows[i].imdb_id + "')")1344 .writeElement('title', shows[i].title)1345 .writeElement('subtitle', shows[i].year + ' | ' + shows[i].num_seasons + ' Seasons')1346 .writeElement('image', shows[i].images.poster)1347 .writeElement('defaultImage', 'resource://Poster.png')1348 .endElement();1349 }1350 xw.startElement('moviePoster')1351 .writeAttribute('id', "50")1352 .writeAttribute('alwaysShowTitles', 'true')1353 .writeAttribute('onPlay', 'loadMore("tv", "' + sort_by + '", "2")')1354 .writeAttribute('onSelect', 'loadMore("tv", "' + sort_by + '", "2")')1355 .writeElement('title', 'View More')1356 .writeElement('subtitle', '')1357 .writeElement('image', 'http://trailers.apple.com/thumbnails/view-more.png')1358 .writeElement('defaultImage', 'resource://Poster.png')1359 .endElement();1360 xw.endDocument();1361 logger.Debug(xw.toString());1362 callback(xw.toString());1363 });1364}1365function generateTVSeasons(imdb, seriesTitle, callback){1366 var XMLWriter = require('xml-writer');1367 xw = new XMLWriter;1368 var API = require('./TVApi');1369 var tv = API.getSeasons(imdb, function(seasons, seasonNumbers){1370 xw.startDocument(version='1.0', encoding='UTF-8');1371 xw.startElement('atv')1372 .startElement('body')1373 .startElement('scroller').writeAttribute('id', 'com.sample.menu-items-with-sections')1374 .startElement('header')1375 .startElement('simpleHeader')1376 .writeElement('title', seriesTitle)1377 .endElement()1378 .endElement()1379 .startElement('items')1380 .startElement('collectionDivider')1381 .writeAttribute('alignment', 'left')1382 .writeElement('title', '')1383 .endElement()1384 .startElement('shelf')1385 .writeAttribute('id', 'coverflow').writeAttribute('columnCount', Math.min(seasonNumbers.length, 5))1386 .startElement('sections')1387 .startElement('shelfSection')1388 .startElement('items');1389 for(var i = 0; i <= seasons.length-1; i++)1390 {1391 if (seasonNumbers.indexOf(i) > -1){1392 if (i == 0){1393 title = "Specials"1394 } else {1395 var title = 'Season ' + i;1396 }1397 if (seasons[i].images.poster.thumb == null){1398 seasons[i].images.poster.thumb = 'resource://Poster.png';1399 }1400 var url = 'http://trailers.apple.com/episodes.xml?imdb=' + imdb + '&season=' + i + '&title=' + seriesTitle.replace(/ /g,"%20");1401 xw.startElement('goldenPoster')1402 .writeAttribute('id', i)1403 .writeAttribute('alwaysShowTitles', 'true')1404 .writeAttribute('onPlay', 'atv.loadURL("' + url + '")')1405 .writeAttribute('onSelect', 'atv.loadURL("' + url + '")')1406 .writeAttribute('onHoldSelect', 'scrobbleMenu("http://trailers.apple.com/scrobble.xml?type=tvshow&id=' + imdb + '")')1407 .writeElement('title', title)1408 .writeElement('image', seasons[i].images.poster.thumb)1409 .writeElement('defaultImage', 'resource://Poster.png')1410 .endElement();1411 }1412 }1413 xw.endElement()1414 .endElement()1415 .endElement()1416 .endElement()1417 .startElement('collectionDivider')1418 .writeAttribute('alignment', 'left')1419 .writeElement('title', '')1420 .endElement();1421 xw.endDocument();1422 logger.Debug(xw.toString());1423 callback(xw.toString());1424 });1425}1426function generateTVSeasonsFanart(imdb, seriesTitle, resolution, callback){1427 var inset1 = '-434';1428 var inset2 = '900';1429 if (resolution == '720'){1430 inset1 = '-270';1431 inset2 = '580';1432 }1433 var XMLWriter = require('xml-writer');1434 xw = new XMLWriter;1435 var API = require('./TVApi');1436 var tv = API.getSeasonsFanart(imdb, resolution, function(seasons, seasonNumbers, fanart){1437 xw.startDocument(version='1.0', encoding='UTF-8');1438 xw.startElement('atv')1439 .startElement('body')1440 .startElement('scroller').writeAttribute('id', 'com.sample.menu-items-with-sections')1441 .startElement('header')1442 .startElement('imageHeader')1443 .startElement('image')1444 .writeAttribute('insets', inset1 + ', 0, ' + inset2 + ', 0')1445 .writeAttribute('required', 'true')1446 .text(fanart)1447 .endElement()1448 .endElement()1449 .endElement()1450 .startElement('items')1451 .startElement('shelf')1452 .writeAttribute('id', 'coverflow').writeAttribute('columnCount', Math.min(seasonNumbers.length, 7))1453 .startElement('sections')1454 .startElement('shelfSection')1455 .startElement('items');1456 for(var i = 0; i <= seasons.length-1; i++)1457 {1458 if (seasonNumbers.indexOf(seasons[i].number) > -1){1459 if (seasons[i].number == 0){1460 title = "Specials"1461 } else {1462 var title = 'Season ' + seasons[i].number;1463 }1464 if (seasons[i].images.poster.thumb == null){1465 seasons[i].images.poster.thumb = 'resource://Poster.png';1466 }1467 var url = 'http://trailers.apple.com/episodes.xml?imdb=' + imdb + '&season=' + seasons[i].number + '&title=' + seriesTitle.replace(/ /g,"%20");1468 xw.startElement('moviePoster')1469 .writeAttribute('id', i)1470 .writeAttribute('alwaysShowTitles', 'true')1471 .writeAttribute('onPlay', 'atv.loadURL("' + url + '")')1472 .writeAttribute('onSelect', 'atv.loadURL("' + url + '")')1473 .writeElement('title', title)1474 .writeElement('image', seasons[i].images.poster.thumb)1475 .writeElement('defaultImage', 'resource://Poster.png')1476 .endElement();1477 }1478 }1479 xw.endDocument();1480 logger.Debug(xw.toString());1481 callback(xw.toString());1482 });1483}1484function generateTVEpisodes(imdb, season, title, callback){1485 var XMLWriter = require('xml-writer');1486 xw = new XMLWriter;1487 var API = require('./TVApi');1488 var tv = API.getEpisodes(imdb, season, function(episodes, episodeNumbers, fanart){1489 if (season == '0'){1490 var subtitle = 'Specials'1491 } else {1492 var subtitle = 'Season ' + season;1493 }1494 xw.startDocument(version='1.0', encoding='UTF-8');1495 xw.startElement('atv')1496 .startElement('head')1497 .startElement('script')1498 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')1499 .endElement()1500 .endElement()1501 .startElement('body')1502 .startElement('listWithPreview').writeAttribute('id', 'com.sample.menu-items-with-sections')1503 .startElement('header')1504 .startElement('simpleHeader')1505 .writeElement('title', title)1506 .writeElement('subtitle', subtitle)1507 .endElement()1508 .endElement()1509 .startElement('menu')1510 .startElement('sections')1511 .startElement('menuSection')1512 .startElement('items');1513 for(var i = 0; i <= episodes.length; i++)1514 {1515 var num = i+1;1516 if (episodeNumbers.indexOf(num) > -1){1517 if (episodes[i].title == null){1518 continue;1519 }1520 if (episodes[i].overview == null){1521 episodes[i].overview = 'No Overview';1522 }1523 if (episodes[i].images.screenshot.thumb == null){1524 episodes[i].images.screenshot.thumb = 'resource://16x9.png';1525 }1526 logger.Debug(episodes[i]);1527 var url = 'http://trailers.apple.com/TVPrePlay.xml?imdb=' + imdb + '&season=' + season + '&episode=' + episodes[i].number;1528 xw.startElement('twoLineEnhancedMenuItem')1529 .writeAttribute('id', episodes[i].ids.trakt)1530 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')1531 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')1532 .writeElement('label', 'Episode ' + episodes[i].number)1533 .writeElement('rightLabel', episodes[i].title)1534 .writeElement('image', episodes[i].images.screenshot.thumb)1535 .writeElement('defaultImage', 'resource://16x9.png')1536 .startElement('preview')1537 .startElement('keyedPreview')1538 .writeElement('title', episodes[i].title)1539 .writeElement('summary', episodes[i].overview)1540 .writeElement('image', episodes[i].images.screenshot.thumb)1541 .startElement('metadataKeys')1542 .writeElement('label', 'Resolution')1543 .endElement()1544 .startElement('metadataValues')1545 .writeElement('label', '720p')1546 .endElement()1547 .endElement()1548 .endElement()1549 .endElement();1550 }1551 }1552 xw.endDocument();1553 logger.Debug(xw.toString());1554 callback(xw.toString());1555 });1556}1557function generateTVPrePlayXML(imdb, season, episode, UDID, quality, subtitle, aTVversion, callback){1558 var API = require('./TVApi');1559 var tmpEp = episode;1560 var episode = API.getEpisode(imdb, season, episode, function(show, moreEpisodes, episodeNumbers, torrentLink, poster, fullShow){1561 if (show.images.screenshot.full == null){1562 show.images.screenshot.full = 'resource://16x9.png';1563 }1564 if (show.overview == null){1565 show.overview = 'No Overview could be Found.';1566 }1567 var XMLWriter = require('xml-writer');1568 var url = "http://trailers.apple.com/Movies/TVPrePlay.xml?imdb=" + imdb + '&season=' + season + '&episode=' + tmpEp + '&UDID=' + UDID;1569 var torrentURL = encodeURIComponent(selectTorrentTV(torrentLink, quality).replace(/%5B/g, '').replace(/%5D/g, ''));1570 xw = new XMLWriter;1571 xw.startDocument(version='1.0', encoding='UTF-8');1572 xw.startElement('atv')1573 .startElement('head')1574 .startElement('script')1575 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')1576 .endElement()1577 .endElement()1578 .startElement('body')1579 .startElement('itemDetail')1580 .writeAttribute('id', 'com.apple.trailer')1581 .writeElement('title', show.title)1582 .writeElement('subtitle', fullShow.network);1583 if (fullShow.certification != null)1584 xw.writeElement('rating', fullShow.certification);1585 xw.writeElement('summary', show.overview)1586 .startElement('image')1587 .writeAttribute('style', 'sixteenByNinePoster')1588 .text(show.images.screenshot.full)1589 .endElement()1590 .writeElement('defaultImage', 'resource://16x9.png')1591 .startElement('table')1592 .startElement('columnDefinitions')1593 .startElement('columnDefinition')1594 .writeAttribute('alignment', 'left')1595 .writeAttribute('width', '50')1596 .writeElement('title', 'Details')1597 .endElement()1598 .endElement()1599 .startElement('rows')1600 .startElement('row')1601 .writeElement('label', parseGenre(fullShow.genres))1602 .endElement()1603 .startElement('row')1604 .writeElement('label', parseTime(fullShow.runtime))1605 .endElement();1606 if (parseInt(aTVversion) >= 6){1607 xw.startElement('row')1608 .startElement('mediaBadges')1609 .startElement('additionalMediaBadges');1610 var num = 0;1611 getQualitiesTV(torrentLink).forEach(function(quality){1612 xw.startElement('urlBadge')1613 .writeAttribute('insertIndex', num)1614 .writeAttribute('required', 'true')1615 .writeAttribute('src', 'http://trailers.apple.com/thumbnails/MediaBadges/' + quality + '.png')1616 .endElement();1617 num += 1;1618 })1619 xw.endElement()1620 .endElement()1621 .endElement();1622 }1623 xw.startElement('row')1624 .startElement('starRating')1625 .writeElement('percentage', Math.round(show.rating * 10))1626 .endElement()1627 .endElement()1628 .endElement()1629 .endElement()1630 .startElement('centerShelf')1631 .startElement('shelf')1632 .writeAttribute('id', 'centerShelf')1633 .writeAttribute('columnCount', '4')1634 .writeAttribute('center', 'true')1635 .startElement('sections')1636 .startElement('shelfSection')1637 .startElement('items')1638 .startElement('actionButton')1639 .writeAttribute('id', 'play')1640 .writeAttribute('onSelect', "atv.loadURL('" + encodeURI("http://trailers.apple.com/Movies/MoviePlay.xml?id=" + imdb + "&UDID=" + UDID + "&title=" + encodeURIComponent(show.title.replace(/'/g, '')) + "&desc=" + encodeURIComponent(show.overview.replace(/'/g, '')) + "&poster=" + show.images.screenshot.thumb + "&torrent=" + torrentURL + '&subtitle=' + subtitle) + "')")1641 .writeElement('title', 'Play')1642 .writeElement('image', 'resource://Play.png')1643 .writeElement('focusedImage', 'resource://PlayFocused.png')1644 .endElement()1645 .startElement('actionButton')1646 .writeAttribute('id', 'select')1647 .writeAttribute('onSelect', "atv.loadURL('http://trailers.apple.com/qualitytv.xml?imdb=" + imdb + '&season=' + season + '&episode=' + tmpEp + '&UDID=' + UDID + '&qualities=' + getQualitiesTV(torrentLink) + '&subtitle=' + subtitle + "')")1648 .writeElement('title', 'Select Quality')1649 .writeElement('image', 'resource://Queue.png')1650 .writeElement('focusedImage', 'resource://QueueFocused.png')1651 .endElement()1652 .startElement('actionButton')1653 .writeAttribute('id', 'subtitle')1654 .writeAttribute('onSelect', "atv.loadURL('http://trailers.apple.com/subtitlestv.xml?imdb=" + imdb + "&episode=" + tmpEp + '&season=' + season + '&UDID=' + UDID + '&quality=' + quality + "')")1655 .writeElement('title', 'Subtitles')1656 .writeElement('image', 'resource://Queue.png')1657 .writeElement('focusedImage', 'resource://QueueFocused.png')1658 .endElement()1659 .endElement()1660 .endElement()1661 .endElement()1662 .endElement()1663 .endElement()1664 .startElement('divider')1665 .startElement('smallCollectionDivider')1666 .writeAttribute('alignment', 'left')1667 .writeElement('title', 'Related Movies')1668 .endElement()1669 .endElement()1670 .startElement('bottomShelf')1671 .startElement('shelf')1672 .writeAttribute('columnCount', '7')1673 .writeAttribute('id', 'bottomShelf')1674 .startElement('sections')1675 .startElement('shelfSection')1676 .startElement('items');1677 moreEpisodes.forEach(function(ep){1678 var url = "http://trailers.apple.com/Movies/TVPrePlay.xml?imdb=" + imdb + '&season=' + season + '&episode=' + ep.number + '&UDID=' + UDID;1679 if (ep.title == null){1680 return;1681 }1682 if (ep.images.screenshot.thumb == null){1683 ep.images.screenshot.thumb = 'resource://16x9.png';1684 }1685 xw.startElement('moviePoster')1686 .writeAttribute('id', 'test')1687 .writeAttribute('alwaysShowTitles', 'true')1688 .writeAttribute('related', 'true')1689 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')1690 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')1691 .writeElement('title', ep.title)1692 .writeElement('subtitle', "Episode " + ep.number)1693 .writeElement('image', ep.images.screenshot.thumb)1694 .writeElement('defaultImage', 'resource://16x9.png')1695 .endElement();1696 })1697 xw.endDocument();1698 logger.Debug(xw.toString());1699 logger.Debug(selectTorrentTV(torrentLink, quality));1700 callback(xw.toString());1701 });1702}1703function generatePrePlayFanartXML(show, options, quality, subtitle, callback){1704 var inset = '690';1705 if (options.resolution == '720'){1706 inset = '460';1707 }1708 logger.warning(show);1709 if (show.description == null){1710 show.description = 'No Overview could be Found.';1711 }1712 var XMLWriter = require('xml-writer');1713 var url = "http://trailers.apple.com/Movies/TVPrePlay.xml?imdb=" + options.imdb + '&season=' + options.season + '&episode=' + options.episode + '&UDID=' + options.UDID;1714 var parseTorrent = require('parse-torrent');1715 var infoHash = parseTorrent(selectTorrentTV(show.torrents, quality)).infoHash;1716 var torrentURL = encodeURIComponent(selectTorrentTV(show.torrents, quality).replace(/%5B/g, '').replace(/%5D/g, ''));1717 xw = new XMLWriter;1718 xw.startDocument(version='1.0', encoding='UTF-8');1719 xw.startElement('atv')1720 .startElement('head')1721 .startElement('script')1722 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')1723 .endElement()1724 .endElement()1725 .startElement('body')1726 .startElement('itemDetailWithImageHeader')1727 .writeAttribute('id', 'com.apple.trailer')1728 .writeAttribute('layout', 'compact')1729 .startElement('styles')1730 .startElement('color')1731 .writeAttribute('name', 'titleColor')1732 .text('#fafafa')1733 .endElement()1734 .startElement('color')1735 .writeAttribute('name', 'metadataColor')1736 .text('#fafafa')1737 .endElement()1738 .endElement()1739 .startElement('header')1740 .startElement('imageHeader')1741 .startElement('image')1742 .writeAttribute('insets', '0, 0, ' + inset + ', 0')1743 .writeAttribute('required', 'true')1744 .text(show.images.fanart)1745 .endElement()1746 .endElement()1747 .endElement()1748 .writeElement('title', show.title)1749 .writeElement('footnote', show.year);1750 if (show.rating != null)1751 xw.writeElement('rating', show.rating);1752 xw.writeElement('summary', show.description)1753 .startElement('userRatings')1754 .startElement('starRating')1755 .writeElement('percentage', show.rt_rating)1756 .endElement()1757 .endElement()1758 .startElement('image')1759 .writeAttribute('style', 'moviePoster')1760 .text(show.images.poster)1761 .endElement()1762 .writeElement('defaultImage', 'resource://Poster.png')1763 .startElement('table')1764 .startElement('columnDefinitions')1765 .startElement('columnDefinition')1766 .writeAttribute('alignment', 'left')1767 .writeAttribute('width', '50')1768 .writeElement('title', 'Details')1769 .endElement()1770 .endElement()1771 .startElement('rows')1772 .startElement('row')1773 .writeElement('label', parseGenre(show.genres))1774 .endElement()1775 .startElement('row')1776 .writeElement('label', parseTime(show.runtime))1777 .endElement()1778 .startElement('row')1779 .startElement('mediaBadges')1780 .startElement('additionalMediaBadges')1781 var num = 0;1782 getQualitiesTV(show.torrents).forEach(function(quality){1783 xw.startElement('urlBadge')1784 .writeAttribute('insertIndex', num)1785 .writeAttribute('required', 'true')1786 .writeAttribute('src', 'http://trailers.apple.com/thumbnails/MediaBadges/' + quality + '.png')1787 .endElement();1788 num += 1;1789 })1790 xw.endElement()1791 .endElement()1792 .endElement()1793 .endElement()1794 .endElement()1795 .startElement('centerShelf')1796 .startElement('shelf')1797 .writeAttribute('id', 'centerShelf')1798 .writeAttribute('columnCount', '4')1799 .writeAttribute('center', 'true')1800 .startElement('sections')1801 .startElement('shelfSection')1802 .startElement('items')1803 .startElement('actionButton')1804 .writeAttribute('id', 'play')1805 .writeAttribute('onSelect', "atv.loadURL('" + encodeURI("http://trailers.apple.com/Movies/MoviePlay.xml?id=" + options.imdb + "&UDID=" + options.UDID + "&title=" + encodeURIComponent(show.title.replace(/'/g, '')) + "&desc=" + encodeURIComponent(show.description.replace(/'/g, '')) + "&poster=" + show.images.poster + "&torrent=" + torrentURL + '&subtitle=' + subtitle + '&hash=' + infoHash) + "')")1806 .writeElement('title', 'Play')1807 .writeElement('image', 'resource://Play.png')1808 .writeElement('focusedImage', 'resource://PlayFocused.png')1809 .endElement()1810 .startElement('actionButton')1811 .writeAttribute('id', 'select')1812 .writeAttribute('onSelect', "atv.loadURL('http://trailers.apple.com/qualitytv.xml?imdb=" + options.imdb + '&season=' + options.season + '&episode=' + options.episode + '&UDID=' + options.UDID + '&qualities=' + getQualitiesTV(show.torrents) + '&subtitle=' + subtitle + "')")1813 .writeElement('title', 'Select Quality')1814 .writeElement('image', 'resource://Queue.png')1815 .writeElement('focusedImage', 'resource://QueueFocused.png')1816 .endElement()1817 .startElement('actionButton')1818 .writeAttribute('id', 'subtitle')1819 .writeAttribute('onSelect', "atv.loadURL('http://trailers.apple.com/subtitlestv.xml?imdb=" + options.imdb + "&episode=" + options.episode + '&season=' + options.season + '&UDID=' + options.UDID + '&quality=' + quality + "')")1820 .writeElement('title', 'Subtitles')1821 .writeElement('image', 'resource://Queue.png')1822 .writeElement('focusedImage', 'resource://QueueFocused.png')1823 .endElement()1824 .endElement()1825 .endElement()1826 .endElement()1827 .endElement()1828 .endElement()1829 .startElement('divider')1830 .startElement('smallCollectionDivider')1831 .writeAttribute('alignment', 'left')1832 .writeElement('title', 'More Episodes')1833 .endElement()1834 .endElement()1835 .startElement('bottomShelf')1836 .startElement('shelf')1837 .writeAttribute('columnCount', '7')1838 .writeAttribute('id', 'bottomShelf')1839 .startElement('sections')1840 .startElement('shelfSection')1841 .startElement('items');1842 show.related.forEach(function(ep){1843 var url = "http://trailers.apple.com/Movies/TVPrePlay.xml?imdb=" + options.imdb + '&season=' + options.season + '&episode=' + ep.number;1844 if (ep.title == null){1845 return;1846 }1847 if (ep.screenshot == null){1848 ep.screenshot = 'resource://16x9.png';1849 }1850 xw.startElement('moviePoster')1851 .writeAttribute('id', 'test')1852 .writeAttribute('alwaysShowTitles', 'true')1853 .writeAttribute('related', 'true')1854 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')1855 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')1856 .writeElement('title', ep.title)1857 .writeElement('subtitle', ep.subtitle)1858 .writeElement('image', ep.screenshot)1859 .writeElement('defaultImage', 'resource://16x9.png')1860 .endElement();1861 })1862 xw.endDocument();1863 logger.Debug(xw.toString());1864 callback(xw.toString());1865}1866function generateFavoritesXML(favorites, callback){1867 var XMLWriter = require('xml-writer');1868 xw = new XMLWriter;1869 xw.startDocument(version='1.0', encoding='UTF-8');1870 xw.startElement('atv')1871 .startElement('head')1872 .startElement('script')1873 .writeAttribute('src', 'http://trailers.apple.com/js/utils.js')1874 .endElement()1875 .endElement()1876 .startElement('body')1877 .startElement('scroller').writeAttribute('id', 'com.sample.movie-grid')1878 .startElement('header')1879 .startElement('simpleHeader')1880 .writeElement('title', 'Favorites')1881 .endElement()1882 .endElement()1883 .startElement('items')1884 .startElement('grid')1885 .writeAttribute('columnCount', '7').writeAttribute('id', 'grid_0')1886 .startElement('items');1887 var processed = 0;1888 favorites.forEach(function(favorite){1889 if (favorite.type == 'movie'){1890 var API = require('./MoviesAPI');1891 var movies = API.getMovie(favorite.id, function(movie){1892 var url = "http://trailers.apple.com/Movies/MoviePrePlay.xml?torrentID=" + movie.id;1893 xw.startElement('moviePoster')1894 .writeAttribute('id', movie.title.replace(/\s/g, ''))1895 .writeAttribute('alwaysShowTitles', 'true')1896 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')1897 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')1898 .writeAttribute('onHoldSelect', 'scrobbleMenu("http://trailers.apple.com/scrobble.xml?type=movie&id=' + movie.id + '")')1899 .writeElement('title', movie.title)1900 .writeElement('subtitle', movie.year)1901 .writeElement('image', movie.images.medium_cover_image)1902 .writeElement('defaultImage', 'resource://Poster.png')1903 .endElement();1904 processed += 1;1905 if (processed == favorites.length){1906 xw.endDocument();1907 logger.Debug(xw.toString());1908 callback(xw.toString());1909 }1910 });1911 } else if (favorite.type == 'tvshow' || favorite.type == 'tv'){1912 var API = require('./TVApi');1913 var tv = API.getShow(favorite.id, function(show){1914 var url = 'http://trailers.apple.com/seasons.xml?imdb=' + show.imdb_id + '&title=' + show.title.replace(/ /g,"%20");1915 xw.startElement('moviePoster')1916 .writeAttribute('id', show.title.replace(/\s/g, ''))1917 .writeAttribute('alwaysShowTitles', 'true')1918 .writeAttribute('onPlay', 'addUDIDtoQuery("' + url + '")')1919 .writeAttribute('onSelect', 'addUDIDtoQuery("' + url + '")')1920 .writeAttribute('onHoldSelect', "scrobbleMenu('http://trailers.apple.com/scrobble.xml?type=tv&id=" + show.imdb_id + "')")1921 .writeElement('title', show.title)1922 .writeElement('subtitle', show.year + ' | ' + show.num_seasons + ' Seasons')1923 .writeElement('image', show.images.poster)1924 .writeElement('defaultImage', 'resource://Poster.png')1925 .endElement();1926 processed += 1;1927 if (processed == favorites.length){1928 xw.endDocument();1929 logger.Debug(xw.toString());1930 callback(xw.toString());1931 }1932 });1933 }1934 })1935}1936function parseTime(runtime){1937 var hour = parseInt(Math.floor(runtime)/60)1938 var minute = runtime%601939 if (hour == 0){1940 return minute + 'min';1941 } else if (minute == 0){1942 return hour + 'hr';1943 } else {1944 return hour + 'hr ' + minute + 'min';1945 }1946}1947function parseGenre(genres){1948 if (genres.length == 0){1949 return 'No Known Genres';1950 }1951 if (genres[1] != undefined){1952 return capitalizeFirstLetter(genres[0]) + '/' + capitalizeFirstLetter(genres[1]); // Trakt.tv Genres are Lowercase so we capitalize them :)1953 } else {1954 return capitalizeFirstLetter(genres[0]);1955 }1956}1957function capitalizeFirstLetter(string) {1958 return string.charAt(0).toUpperCase() + string.slice(1);1959}1960function nullCheck(string){1961 if (string == null){1962 return 'Undefined';1963 } else {1964 return string;1965 }1966}1967function getQualities(torrents){1968 var quality = [];1969 torrents.forEach(function(torrent){1970 quality.push(torrent.quality);1971 })1972 logger.Debug(quality);1973 return quality;1974}1975function getQualitiesTV(torrents){1976 var quality = [];1977 if (torrents['480p'] != undefined){1978 quality.push('480p')1979 }1980 if (torrents['720p'] != undefined){1981 quality.push('720p')1982 }1983 if (torrents['1080p'] != undefined){1984 quality.push('1080p')1985 }1986 logger.Debug(quality);1987 return quality;1988}1989function torrentHealth(torrent){1990 var health = torrent.seeds / torrent.peers;1991 logger.Debug('Torrent Health: ' + torrent.quality + ': ' + health);1992 if (health >= 1.5){1993 return 'good';1994 } else if (health >= 0.75){1995 return 'ok';1996 } else if (health >= 0.01){1997 return 'bad';1998 }1999 return 'unknown';2000}2001function selectTorrent(torrents, quality){2002 var torrentURL;2003 torrents.forEach(function(torrent){2004 if (torrent.quality === quality){2005 logger.Debug('found quality! ' + torrent.quality + ' | ' + torrent.url);2006 torrentURL = torrent.url;2007 }2008 })2009 if (torrentURL == undefined && quality == '3D'){2010 torrentURL = torrents[torrents.length-1].url;2011 } else if (torrentURL == undefined){2012 torrentURL = torrents[0].url;2013 }2014 return torrentURL;2015}2016function selectTorrentTV(torrents, quality){2017 try {2018 var torrentURL = torrents[quality].url;2019 } catch(e){2020 var torrentURL = undefined;2021 if (torrentURL == undefined && (quality == '3D' || quality == '1080p')){2022 if (torrents['1080p'] != undefined){2023 torrentURL = torrents['1080p'].url;2024 } else if (torrents['720p'] != undefined){2025 torrentURL = torrents['720p'].url;2026 } else if (torrents['480p'] != undefined){2027 torrentURL = torrents['480p'].url;2028 }2029 }2030 if (torrentURL == undefined){2031 torrentURL = torrents[0].url;2032 }2033 }2034 return torrentURL;2035}2036exports.generatePlayXML = generatePlayXML;2037exports.generateProgressXML = generateProgressXML;2038exports.errorXML = errorXML;2039exports.updateContextXML = updateContextXML;2040exports.generateQuality = generateQuality;2041exports.generateSubtitles = generateSubtitles;2042exports.generateQualityTV = generateQualityTV;2043exports.generateSubtitlesTV = generateSubtitlesTV;2044exports.generateSettingsXML = generateSettingsXML;2045exports.generateGenre = generateGenre;2046exports.generateMoviesXML = generateMoviesXML;2047exports.generateScrobbleXML = generateScrobbleXML;2048exports.generateScrobbleXMLOLD = generateScrobbleXMLOLD;2049exports.generateMoviePrePlayXML = generateMoviePrePlayXML;2050exports.generateMoviePrePlayFanartXML = generateMoviePrePlayFanartXML;2051exports.generateMovieParadeXML = generateMovieParadeXML;2052exports.generateTVParadeXML = generateTVParadeXML;2053exports.generateSearchResults = generateSearchResults;2054exports.generateMovieSearchResults = generateMovieSearchResults;2055exports.generateTVSearchResults = generateTVSearchResults;2056exports.generateTVXML = generateTVXML;2057exports.generateTVSeasons = generateTVSeasons;2058exports.generateTVSeasonsFanart = generateTVSeasonsFanart;2059exports.generateTVEpisodes = generateTVEpisodes;2060exports.generateTVPrePlayXML = generateTVPrePlayXML;2061exports.generatePrePlayFanartXML = generatePrePlayFanartXML;2062exports.generateFavoritesXML = generateFavoritesXML;...

Full Screen

Full Screen

dashboard.js

Source:dashboard.js Github

copy

Full Screen

1const Order = require("../models/Order")2const XMLWriter = require('xml-writer')3const axios = require('axios')4module.exports.getOrders = async (req, res) => {5 const orders = await Order.find({}).populate('customer')6 const data = orders.map(o => { return { 7 id: o._id.toString(),8 paymentId: o.paymentId,9 receiptUrl: o.receiptUrl,10 orderId: o.orderId,11 dateCreated: o.dateCreated,12 amount: o.amount,13 items: o.items,14 status: o.status,15 customer: `${o.customer.firstName} ${o.customer.lastName}`16 }})17 res.json(data)18}19module.exports.completeOrder = async (req, res) => {20 const order = await Order.findOne({ _id: req.body.order.id })21 if (order.items) {22 order.items.map(item => {23 if(item._id.toString() === req.body.item._id) {24 item.status = 'completed'25 }26 if(!order.items.filter(i => i.status === 'open').length) {27 order.status = 'completed'28 }29 })30 }31 await order.save()32 const payload = await Order.find({})33 res.json({ message: 'success', payload })34}35module.exports.undoOrder = async (req, res) => {36 const order = await Order.findOne({ _id: req.body.order.id })37 if (order.items) {38 order.items.map(item => {39 if(item._id.toString() === req.body.item._id) {40 item.status = 'open'41 }42 if(order.items.filter(i => i.status === 'open').length > 0) {43 order.status = 'open'44 }45 })46 }47 await order.save()48 const payload = await Order.find({})49 res.json({ message: 'success', payload })50}51module.exports.deleteOrder = async (req, res) => {52 await Order.findOneAndDelete({ _id: req.body.order.id })53 const payload = await Order.find({})54 res.json({ message: 'success', payload })55}56module.exports.printTag = async(req, res) => {57 console.log(req.body.item)58 const payload = new XMLWriter59 payload.startDocument()60 payload.startElement('eVSRequest')61 payload.writeAttribute('USERID', '995MPPRO5353')62 payload.startElement('ImageParameters')63 payload.startElement('LabelSequence')64 payload.startElement('PackageNumber')65 payload.text('1')66 payload.endElement('PackageNumber')67 payload.startElement('TotalPackages')68 payload.text('1')69 payload.endElement('TotalPackages')70 payload.endElement('LabelSequence')71 payload.endElement('ImageParameters')72 payload.startElement('FromName')73 payload.text('Lina Smith')74 payload.endElement('FromName')75 payload.startElement('FromFirm')76 payload.text('Horizon')77 payload.endElement('FromFirm')78 payload.startElement('FromAddress1')79 payload.text('Apt 303')80 payload.endElement('FromAddress1')81 payload.startElement('FromAddress2')82 payload.text('1309 S Agnew Avenue')83 payload.endElement('FromAddress2')84 payload.startElement('FromCity')85 payload.text('Oklahoma City')86 payload.endElement('FromCity')87 payload.startElement('FromState')88 payload.text('OK')89 payload.endElement('FromState')90 payload.startElement('FromZip5')91 payload.text('73108')92 payload.endElement('FromZip5')93 payload.startElement('FromZip4')94 payload.text('2427')95 payload.endElement('FromZip4')96 payload.startElement('FromPhone')97 payload.text('1234567890')98 payload.endElement('FromPhone')99 payload.startElement('AllowNonCleansedOriginAddr')100 payload.text('false')101 payload.endElement('AllowNonCleansedOriginAddr')102 payload.startElement('ToName')103 payload.text('Tall Tom')104 payload.endElement('ToName')105 payload.startElement('ToFirm')106 payload.text('ABC Corp')107 payload.endElement('ToFirm')108 payload.startElement('ToAddress2')109 payload.text('1098 N Fraser Street')110 payload.endElement('ToAddress2')111 payload.startElement('ToCity')112 payload.text('Georgetown')113 payload.endElement('ToCity')114 payload.startElement('ToState')115 payload.text('SC')116 payload.endElement('ToState')117 payload.startElement('ToZip5')118 payload.text('29440')119 payload.endElement('ToZip5')120 payload.startElement('ToZip4')121 payload.text('2849')122 payload.endElement('ToZip4')123 payload.startElement('ToPhone')124 payload.text('8005554526')125 payload.endElement('ToPhone')126 payload.startElement('ToContactPreference')127 payload.text('email')128 payload.endElement('ToContactPreference')129 payload.startElement('ToContactEMail')130 payload.text('talltom@aol.com')131 payload.endElement('ToContactEMail')132 payload.startElement('AllowNonCleansedDestAddr')133 payload.text('false')134 payload.endElement('AllowNonCleansedDestAddr')135 payload.startElement('WeightInOunces')136 payload.text('32')137 payload.endElement('WeightInOunces')138 payload.startElement('ServiceType')139 payload.text('PRIORITY')140 payload.endElement('ServiceType')141 payload.startElement('Container')142 payload.text('VARIABLE')143 payload.endElement('Container')144 payload.startElement('Width')145 payload.text('5.5')146 payload.endElement('Width')147 payload.startElement('Length')148 payload.text('11')149 payload.endElement('Length')150 payload.startElement('Height')151 payload.text('11')152 payload.endElement('Height')153 payload.startElement('Machinable')154 payload.text('TRUE')155 payload.endElement('Machinable')156 payload.startElement('InsuredAmount')157 payload.text('100.00')158 payload.endElement('InsuredAmount')159 payload.startElement('AddressServiceREquested')160 payload.text('true')161 payload.endElement('AddressServiceREquested')162 payload.startElement('CustomerRefNo')163 payload.text('EF789UJK')164 payload.endElement('CustomerRefNo')165 payload.startElement('CustomerRefNo2')166 payload.text('EE66GG87')167 payload.endElement('CustomerRefNo2')168 payload.startElement('ExtraServices')169 payload.startElement('ExtraService')170 payload.text('120')171 payload.endElement('ExtraService')172 payload.endElement('ExtraServices')173 payload.startElement('CRID')174 payload.text('4569873')175 payload.endElement('CRID')176 payload.startElement('MID')177 payload.text('456789354')178 payload.endElement('MID')179 payload.startElement('VendorCode')180 payload.text('1234')181 payload.endElement('VendorCode')182 payload.startElement('VendorProductVersionNumber')183 payload.text('5.02.1B')184 payload.endElement('VendorProductVersionNumber')185 payload.startElement('SenderName')186 payload.text('Adam Johnson')187 payload.endElement('SenderName')188 payload.startElement('SenderEMail')189 payload.text('Adam1234d@aol.com')190 payload.endElement('SenderEMail')191 payload.startElement('RecipientName')192 payload.text('Robert Jones')193 payload.endElement('RecipientName')194 payload.startElement('RecipientEMail')195 payload.text('bobjones@aol.com')196 payload.endElement('RecipientEMail')197 payload.startElement('RecipientOption')198 payload.text('SAME PAGE')199 payload.endElement('RecipientOption')200 payload.startElement('ImageType')201 payload.text('PDF')202 payload.endElement('ImageType')203 payload.startElement('HoldForManifest')204 payload.text('N')205 payload.endElement('HoldForManifest')206 payload.startElement('NineDigitRoutingZip')207 payload.text('false')208 payload.endElement('NineDigitRoutingZip')209 payload.startElement('ShipInfo')210 payload.text('True')211 payload.endElement('ShipInfo')212 payload.startElement('CarrierRelease')213 payload.text('False')214 payload.endElement('CarrierRelease')215 payload.startElement('ReturnCommitments')216 payload.text('True')217 payload.endElement('ReturnCommitments')218 payload.startElement('PrintCustomerRefNo')219 payload.text('False')220 payload.endElement('PrintCustomerRefNo')221 payload.startElement('PrintCustomerRefNo2')222 payload.text('True')223 payload.endElement('PrintCustomerRefNo2')224 payload.startElement('Content')225 payload.startElement('ContentType')226 payload.text('Perishable')227 payload.endElement('ContentType')228 payload.startElement('ContentDescription')229 payload.text('Other')230 payload.endElement('ContentDescription')231 payload.endElement('Content')232 payload.startElement('ActionCode')233 payload.text('M0')234 payload.endElement('ActionCode')235 payload.startElement('OptOutOfSPE')236 payload.text('false')237 payload.endElement('OptOutOfSPE')238 payload.endElement('eVSRequest')239 payload.endDocument()240 await axios({241 method: 'GET',242 url: 'https://secure.shippingapis.com/ShippingAPI.dll?API=eVS&XML=' + payload.toString()243 }).then( res => console.log(res))...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {key: 'A.12345678901234567890123456789012'};3var wpt = new WebPageTest('www.webpagetest.org', options);4wpt.endElement('testId', 'elementId', function(err, data) {5 if (err) {6 console.log('Error: ' + err);7 } else {8 console.log(data);9 }10});11var wpt = require('webpagetest');12var options = {key: 'A.12345678901234567890123456789012'};13var wpt = new WebPageTest('www.webpagetest.org', options);14wpt.endElement('testId', 'elementId', function(err, data) {15 if (err) {16 console.log('Error: ' + err);17 } else {18 console.log(data);19 }20});21var wpt = require('webpagetest');22var options = {key: 'A.12345678901234567890123456789012'};23var wpt = new WebPageTest('www.webpagetest.org', options);24wpt.endElement('testId', 'elementId', function(err, data) {25 if (err) {26 console.log('Error: ' + err);27 } else {28 console.log(data);29 }30});31var wpt = require('webpagetest');32var options = {key: 'A.12345678901234567890123456789012'};33var wpt = new WebPageTest('www.webpagetest.org', options);34wpt.endElement('testId', 'elementId', function(err, data) {35 if (err) {36 console.log('Error: ' + err);37 } else {38 console.log(data);39 }40});41var wpt = require('webpagetest');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var webPageTest = new wpt('www.webpagetest.org');3 if (err) {4 console.error(err);5 } else {6 console.log(data);7 }8});9var wpt = require('webpagetest');10var webPageTest = new wpt('www.webpagetest.org');11webPageTest.getLocations(function(err, data) {12 if (err) {13 console.error(err);14 } else {15 console.log(data);16 }17});18var wpt = require('webpagetest');19var webPageTest = new wpt('www.webpagetest.org');20webPageTest.getTesters(function(err, data) {21 if (err) {22 console.error(err);23 } else {24 console.log(data);25 }26});27var wpt = require('webpagetest');28var webPageTest = new wpt('www.webpagetest.org');29webPageTest.getTesters(function(err, data) {30 if (err) {31 console.error(err);32 } else {33 console.log(data);34 }35});36var wpt = require('webpagetest');37var webPageTest = new wpt('www.webpagetest.org');38webPageTest.getTesters(function(err, data) {39 if (err) {40 console.error(err);41 } else {42 console.log(data);43 }44});45var wpt = require('webpagetest');46var webPageTest = new wpt('www.webpagetest.org');47webPageTest.getTesters(function(err, data) {48 if (err) {49 console.error(err);50 } else {51 console.log(data);52 }53});54var wpt = require('webpagetest');55var webPageTest = new wpt('www.webpagetest.org');

Full Screen

Using AI Code Generation

copy

Full Screen

1function test() {2 var wpt = new WebPageTest();3 wpt.endElement();4}5function test() {6 var wpt = new WebPageTest();7 wpt.endElement();8}9function test() {10 var wpt = new WebPageTest();11 wpt.endElement();12}13function test() {14 var wpt = new WebPageTest();15 wpt.endElement();16}17function test() {18 var wpt = new WebPageTest();19 wpt.endElement();20}21function test() {22 var wpt = new WebPageTest();23 wpt.endElement();24}25function test() {26 var wpt = new WebPageTest();27 wpt.endElement();28}29function test() {30 var wpt = new WebPageTest();31 wpt.endElement();32}33function test() {34 var wpt = new WebPageTest();35 wpt.endElement();36}37function test() {38 var wpt = new WebPageTest();39 wpt.endElement();40}41function test() {42 var wpt = new WebPageTest();43 wpt.endElement();44}45function test() {46 var wpt = new WebPageTest();47 wpt.endElement();48}49function test() {50 var wpt = new WebPageTest();51 wpt.endElement();52}53function test() {

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var wp = new wptoolkit();3var path = require('path');4var fs = require('fs');5var xml = fs.readFileSync(path.join(__dirname, 'test.xml'), 'utf8');6wp.parseString(xml, function(err, result) {7 if (err) {8 console.log('error in parsing xml');9 return;10 }11 console.log(result);12 var xml = wp.endElement();13 console.log(xml);14});15{ note: 16 { to: 'Tove',17 body: 'Don\'t forget me this weekend!' } }18Copyright (c) 2016-2017, Arun Prakash Jana <

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org');3test.endElement('testId', 'elementId', function(err, data) {4 if (err) {5 console.log(err);6 } else {7 console.log(data);8 }9});10var wpt = require('webpagetest');11var test = new wpt('www.webpagetest.org');12test.getLocations(function(err, data) {13 if (err) {14 console.log(err);15 } else {16 console.log(data);17 }18});19var wpt = require('webpagetest');20var test = new wpt('www.webpagetest.org');21test.getTesters(function(err, data) {22 if (err) {23 console.log(err);24 } else {25 console.log(data);26 }27});28var wpt = require('webpagetest');29var test = new wpt('www.webpagetest.org');30test.getTestStatus('testId', function(err, data) {31 if (err) {32 console.log(err);33 } else {34 console.log(data);35 }36});37var wpt = require('webpagetest');38var test = new wpt('www.webpagetest.org');39test.getTestResults('testId', function(err, data) {40 if (err) {41 console.log(err);42 } else {43 console.log(data);44 }45});46var wpt = require('webpagetest');47var test = new wpt('www.webpagetest.org');48test.getTestResults('testId', function(err, data) {49 if (err) {50 console.log(err);51 } else {52 console.log(data);53 }54});55var wpt = require('webpagetest');56var test = new wpt('www.webpagetest.org');57test.getTestResults('testId

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wiki = wptools.page('Barack Obama');3wiki.get(function(err, data) {4 console.log(data);5});6var wptools = require('wptools');7var wiki = wptools.page('Barack Obama');8wiki.get(function(err, data) {9 console.log(data);10});11var wptools = require('wptools');12var wiki = wptools.page('Barack Obama');13wiki.get(function(err, data) {14 console.log(data);15});16var wptools = require('wptools');17var wiki = wptools.page('Barack Obama');18wiki.get(function(err, data) {19 console.log(data);20});21var wptools = require('wptools');22var wiki = wptools.page('Barack Obama');23wiki.get(function(err, data) {24 console.log(data);25});26var wptools = require('wptools');27var wiki = wptools.page('Barack Obama');28wiki.get(function(err, data) {29 console.log(data);30});31var wptools = require('wptools');32var wiki = wptools.page('Barack Obama');33wiki.get(function(err, data) {34 console.log(data);35});36var wptools = require('wptools');37var wiki = wptools.page('Barack Obama');38wiki.get(function(err, data) {39 console.log(data);40});41var wptools = require('wptools');42var wiki = wptools.page('Barack Obama');43wiki.get(function(err, data) {44 console.log(data);45});

Full Screen

Using AI Code Generation

copy

Full Screen

1var xml = require('xml');2var xmlWriter = require('xml-writer');3var xw = new xmlWriter;4xw.startDocument();5xw.startElement('title').text('title').endElement();6xw.startElement('id').text('id').endElement();7xw.startElement('updated').text('2012-11-07T12:00:00Z').endElement();8xw.startElement('author');9xw.startElement('name').text('name').endElement();10xw.startElement('email').text('email').endElement();11xw.endElement();12xw.startElement('content').writeAttribute('type', 'html').text('content').endElement();13xw.endDocument();14console.log(xw.toString());15var xml = require('xml');16var xmlWriter = require('xml-writer');17var xw = new xmlWriter;18xw.startDocument();19xw.startElement('title').text('title').end();20xw.startElement('id').text('id').end();21xw.startElement('updated').text('2012-11-07T12:00:00Z').end();22xw.startElement('author');23xw.startElement('name').text('name').end();24xw.startElement('email').text('email').end();25xw.endElement();26xw.startElement('content').writeAttribute('

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wptoolkit');2wpt.endElement('elementname', 'elementvalue', function(err, result) {3 if(err) {4 console.log(err);5 }6 else {7 console.log(result);8 }9});10var wpt = require('wptoolkit');11wpt.setElement('elementname', 'elementvalue', function(err, result) {12 if(err) {13 console.log(err);14 }15 else {16 console.log(result);17 }18});19var wpt = require('wptoolkit');20wpt.getElement('elementname', function(err, result) {21 if(err) {22 console.log(err);23 }24 else {25 console.log(result);26 }27});28var wpt = require('wptoolkit');29wpt.getElementText('elementname', function(err, result) {30 if(err) {31 console.log(err);32 }33 else {34 console.log(result);35 }36});37var wpt = require('wptoolkit');38wpt.getElementAttribute('elementname', 'attribute', function(err, result) {39 if(err) {40 console.log(err);41 }42 else {43 console.log(result);44 }45});46var wpt = require('wptoolkit');47wpt.getElementHtml('elementname', function(err, result) {48 if(err) {49 console.log(err);50 }51 else {52 console.log(result);53 }54});55var wpt = require('wptoolkit');56wpt.getElementValue('elementname', function(err, result) {57 if(err) {58 console.log(err);59 }60 else {61 console.log(result);62 }63});64var wpt = require('wptoolkit');65wpt.getElementCssValue('elementname', 'cssproperty', function

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful