1 Components.utils.import(
"resource://gre/modules/XPCOMUtils.jsm");
2 Components.utils.import(
"resource://app/jsmodules/sbLibraryUtils.jsm");
3 Components.utils.import(
"resource://app/jsmodules/sbProperties.jsm");
5 const Cc = Components.classes;
6 const Ci = Components.interfaces;
7 const Cr = Components.results;
9 const DESCRIPTION =
"mashTape Provider: YouTube Provider";
10 const CID =
"{e0f43860-6a5c-11dd-ad8b-0800200c9a66}";
11 const CONTRACTID =
"@songbirdnest.com/mashTape/provider/flash/YouTube;1";
15 this.wrappedJSObject =
this;
16 Components.utils.import(
"resource://mashtape/mtUtils.jsm");
25 Ci.sbIMashTapeProvider]),
27 providerName:
"YouTube",
28 providerType:
"flash",
29 providerUrl:
"http://www.youtube.com",
30 providerIcon:
"chrome://mashTape/content/tabs/youtube.png",
31 searchURL:
"http://gdata.youtube.com/feeds/videos?vq=",
33 query:
function(searchTerms, updateFn) {
34 var req =
Cc[
"@mozilla.org/xmlextras/xmlhttprequest;1"]
35 .createInstance(
Ci.nsIXMLHttpRequest);
36 var query =
"%22" + escape(searchTerms) +
"%22";
37 mtUtils.log(
"YouTube",
"URL: " + this.searchURL + query);
38 req.open(
"GET", this.searchURL + query,
true);
40 req.updateFn = updateFn;
41 req.onreadystatechange =
function() {
42 if (this.readyState != 4)
44 if (this.status == 200) {
45 var results =
new Array();
46 var x =
new XML(this.responseText.replace(
47 "<?xml version='1.0' encoding='UTF-8'?>",
""));
50 var atomns =
new Namespace(
'http://www.w3.org/2005/Atom');
51 var medians =
new Namespace(
'http://search.yahoo.com/mrss/');
53 Namespace(
'http://gdata.youtube.com/schemas/2007');
58 for each (var link
in entry.atomns::link) {
59 if (link.@type ==
"text/html") {
67 for each (var media
in entry..medians::content) {
68 if (media.@type ==
"application/x-shockwave-flash") {
77 swfUrl +=
"&enablejsapi=1";
81 var thumbnailWidth = 0;
82 for each (var thumb
in entry..medians::thumbnail) {
83 if (parseInt(thumb.@
width) > thumbnailWidth) {
84 thumbnailWidth = thumb.@
width;
85 thumbnail = thumb.@
url;
90 var dateObj =
new Date();
91 dateObj.setISO8601(entry.atomns::published);
93 var authorUrl =
"http://www.youtube.com/user/" +
94 entry.atomns::author.atomns::name;
97 title: entry.atomns::title,
101 time: dateObj.getTime(),
102 thumbnail: thumbnail,
103 author: entry.atomns::author.atomns::name,
105 authorUrl: authorUrl,
106 description: entry.atomns::content,
107 provider: this.provider.providerName,
108 providerUrl: this.provider.providerUrl,
116 results.wrappedJSObject = results;
117 this.updateFn.wrappedJSObject.update(
CONTRACTID, results);
126 return XPCOMUtils.generateModule([
YouTube]);
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
function NSGetModule(compMgr, fileSpec)
sbDeviceFirmwareAutoCheckForUpdate prototype classID