66 Identity:
function ScraperStep_Identity(scraper,
node, pipeline) {
68 while((properties = yield properties)) {
69 pipeline.send(properties);
79 DocumentURLSource:
function ScraperStep_DocumentURLSource(scraper,
node, pipeline) {
92 ".//embed/@src",
".//*[local-name()='embed']/@src",
93 ".//object/@data",
".//*[local-name()='object']/@data",
94 ".//param/@value",
".//*[local-name()='param']/@value",
95 ".//enclosure/@url",
".//*[local-name()='enclosure']/@url"
99 if (
node.ownerDocument) {
100 nodeDocument =
node.ownerDocument;
109 var results = nodeDocument.evaluate(
110 xpath,
node,
null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
null );
113 scraper._total = results.snapshotLength;
114 for (var
i = 0;
i < results.snapshotLength;
i++) {
115 let contextNode = results.snapshotItem(
i);
116 let
url = contextNode.value;
120 url = nodeDocument.baseURIObject.resolve(url);
129 properties.contextNode = contextNode;
130 properties[SBProperties.originURL] = properties[SBProperties.contentURL] =
url;
133 scraper.job._progress++;
134 scraper.job.notifyJobProgressListeners();
136 pipeline.send(properties);
145 CancelScrape:
function ScraperStep_CancelScrape(scraper,
node, pipeline) {
147 while((properties = yield properties)) {
148 if (scraper._terminate) {
152 pipeline.send(properties);
160 MediaURL:
function ScraperStep_MediaURL(scraper,
node, pipeline) {
161 Components.utils.import(
"resource://app/jsmodules/ArrayConverter.jsm");
162 var typeSniffer =
Cc[
"@songbirdnest.com/Songbird/Mediacore/TypeSniffer;1"]
163 .createInstance(
Ci.sbIMediacoreTypeSniffer);
164 var extensionsEnum = typeSniffer.mediaFileExtensions;
165 if (!
Application.prefs.getValue(
"songbird.mediascan.enableVideo",
false)) {
167 extensionsEnum = typeSniffer.audioFileExtensions;
169 var mediaURLExtensions = [
i for each (
i in ArrayConverter.JSEnum(extensionsEnum))];
170 var mediaURLSchemes = [
"mms",
"rstp"];
173 while ((properties = yield properties)) {
174 var
url =
newURI(properties[SBProperties.contentURL])
175 if (!(url instanceof
Ci.nsIURL)) {
179 if (mediaURLExtensions.indexOf(url.fileExtension) != -1 ||
180 mediaURLSchemes.indexOf(url.scheme) != -1) {
181 pipeline.send(properties);
190 Hacks_DropBadUrls:
function ScraperStep_Hacks_DropBadUrls(scraper,
node, pipeline) {
192 while((properties = yield properties)) {
193 var
url =
newURI(properties[SBProperties.contentURL])
194 if (!(url instanceof
Ci.nsIURL)) {
198 if (url.fileName.indexOf(
"playerID") == 0) {
215 pipeline.send(properties);
225 DupeCheck:
function ScraperStep_DupeCheck(scraper,
node, pipeline) {
227 while ((properties = yield properties)) {
228 if (!scraper._seenURLs[properties[SBProperties.originURL]]) {
229 pipeline.send(properties);
231 scraper._seenURLs[properties[SBProperties.originURL]] =
true;
240 AddOriginPage:
function ScraperStep_AddOriginPage(scraper,
node, pipeline) {
242 if (
node.ownerDocument) {
247 while((properties = yield properties)) {
248 properties[SBProperties.originPage] =
node.URL;
249 properties[SBProperties.originPageImage] =
node.URL;
250 properties[SBProperties.originPageTitle] =
node.title;
251 pipeline.send(properties);
256 CreateMediaItem:
function ScraperStep_CreateMediaItem(scraper,
node, pipeline, mediaList) {
258 while ((properties = yield properties)) {
259 var
url =
newURI(properties[SBProperties.contentURL]);
260 if (!(url instanceof
Ci.nsIURL)) {
271 delete properties.contextNode;
273 var
uri =
newURI(properties[SBProperties.contentURL]);
274 delete properties[SBProperties.contentURL];
279 if (!properties[SBProperties.trackName]) {
280 properties[SBProperties.trackName] = url.fileName;
284 properties[SBProperties.enableAutoDownload] =
"1";
285 properties[SBProperties.downloadButton] =
"1|0|0";
289 var mediaItem = mediaList.library.createMediaItem(
291 SBProperties.createArray(properties));
293 if (!mediaList.contains(mediaItem)) {
294 mediaList.add(mediaItem);
295 pipeline.send(mediaItem);
300 ScanForMetadata:
function ScraperStep_ScanForMetadata(scraper,
node, pipeline) {
301 var metadataService =
302 Components.classes[
"@songbirdnest.com/Songbird/FileMetadataService;1"]
303 .getService(Components.interfaces.sbIFileMetadataService);
306 while(( mediaItem = yield mediaItem )) {
309 var mediaItemsToScan =
Cc[
"@songbirdnest.com/moz/xpcom/threadsafe-array;1"]
310 .createInstance(
Ci.nsIMutableArray);
311 mediaItemsToScan.appendElement(mediaItem,
false);
312 metadataService.read(mediaItemsToScan)
316 pipeline.send(mediaItem);
327 Sink:
function ScraperStep_Sink(scraper,
node, pipeline) {
329 while((properties = yield properties)) {
340 Squawk:
function ScraperStep_Squawk(scraper,
node, pipeline) {
342 while((properties = yield properties)) {
344 for (var
i in properties) {
345 str +=
i +
": " + properties[
i] +
"\n";
347 Components.utils.reportError(str);
348 pipeline.send(properties);
function newURI(aURLString)
_getSelectedPageStyle s i