{ "translatorID" : "649c2836-a94d-4bbe-8e28-6771f283702f", "label" : "TVNZ", "creator" : "Sopheak Hean", "target" : "^http://tvnz\\.co\\.nz", "minVersion" : "1.0", "maxVersion" : "", "priority" : 100, "inRepository" : true, "translatorType" : 4, "lastUpdated":"2010-09-20 10:30:20" } function detectWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == "x" ) return namespace; else return null; } : null; if (doc.location.href.indexOf("/search/") !=-1){ return "multiple"; } else if ((doc.location.href.indexOf("politics-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) || (doc.location.href.indexOf("politics-news/") !=-1) && (doc.location.href.indexOf("/video") !=-1) || (doc.location.href.indexOf("business-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) || (doc.location.href.indexOf("national-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) || (doc.location.href.indexOf("breakfast-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) || (doc.location.href.indexOf("breakfast-news/") !=-1) && (doc.location.href.indexOf("/video") !=-1) || (doc.location.href.indexOf("world-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) || (doc.location.href.indexOf("all-blacks/") !=-1) && (doc.location.href.indexOf("-video") !=-1) || (doc.location.href.indexOf("weather/") !=-1) && (doc.location.href.indexOf("-video") !=-1) || (doc.location.href.indexOf("-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) || (doc.location.href.indexOf("-news/") !=-1) && (doc.location.href.indexOf("/video") !=-1) || (doc.location.href.indexOf("on/") !=-1) && (doc.location.href.indexOf("-video") !=-1) || (doc.location.href.indexOf("up/") !=-1) && (doc.location.href.indexOf("/video") !=-1)){ return "tvBroadcast"; } else if ((doc.location.href.indexOf("news/") !=-1) || (doc.location.href.indexOf("all-blacks/") !=-1) || (doc.location.href.indexOf("up/")!=-1)){ return "newspaperArticle"; } } function scrape(doc, url){ var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == "x" ) return namespace; else return null; } : null; if (detectWeb(doc, url) == "newspaperArticle") { var newItem = new Zotero.Item('newspaperArticle'); newItem.url = doc.location.href; newItem.publicationTitle = "TVNZ"; newItem.language = "English"; var titleXPath = '//h1'; var titleXPathObject = doc.evaluate(titleXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if (titleXPathObject){ var titleXPathString = titleXPathObject.textContent; newItem.title = titleXPathString ; } var dateXPath = '//p[@class="time"]'; var dateXPathObject = doc.evaluate(dateXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if(dateXPathObject){ var dateXPathString = dateXPathObject.textContent.replace(/\W\bPublished:\W\d{1,2}:\d{1,2}(AM|PM) (\w)+ /g, ''); newItem.date = dateXPathString.replace(/^\s*|\s*$/g, ''); } //get Author from the article var authorXPath = '//p[@class="source"]'; var authorXPathObject = doc.evaluate(authorXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if (authorXPathObject){ var authorXPathString = authorXPathObject.textContent.replace(/\W\bSource:\W+/g, ''); newItem.creators.push(Zotero.Utilities.cleanAuthor(authorXPathString.replace(/\W+/g, '-'), "author")); } //get Section of the article var sectionXPath = '//li[@class="selectedLi"]/a/span'; var sectionXPathObject = doc.evaluate(sectionXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); if (sectionXPathObject){ var sectionXPathString = sectionXPathObject.textContent.replace(/^s/g, ''); var sectionArray = new Array("Rugby", "All Blacks", "Cricket", "League", "Football", "Netball", "Basketball", "Tennis", "Motor", "Golf", "Other", "Tipping"); //loop through the Array and check for condition for section category //var count =0; for (var i=0; i