1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
var TVBouquet = function (period, day, tblbouquet, pos, count, TVprogs, callback, callbacknext) {
if (!callback) return;
if (pos == count) return callbacknext(TVprogs);
if (debug == 'true') console.log("period: " + period);
var url = 'http://www.programme.tv/'
'_________________________________________________________________________________
var scrapDay = function(body, bouquet, TVprogs, callback) {
var cherio = require('cheerio')
var $ = cherio.load(body, { xmlMode: true, ignoreWhitespace: false, lowerCaseTags: false });
$('div[class=progchaine]').each(function(index) {
var channelName = $(this).find('.chaine a').attr('title').replace('Programme ', '');
var flagfound = false;
if (msg.MyChannelId(channelName) == true) {
for (var i = 0; i< TVprogs.length; i++) {
if (TVprogs[i].channelName == channelName) {
flagfound = true;
break;
}
}
if (!flagfound) {
var $1 = cherio.load($(this), { xmlMode: true, ignoreWhitespace: false, lowerCaseTags: false });
$1('li').each(function(i, elem) {
var hourStart = $(this).find('.heure').text();
var title = trim($1(this).find('.titre').text());
if (title && title != '') {
var type = trim($1(this).find('.type-tag').text());
if (type)
var duration = trim($1(this).find('.details p').text());
else {
type = 'otherType';
var duration = $(this).find('.duree').text();
}
if (duration && duration != '') {
duration = duration.replace(type + ' - ', '');
if (duration.indexOf('min') != -1)
duration = '00:' + duration.replace(' min','');
duration = duration.replace('h', ':').replace('H', ':');
duration = ((duration.indexOf (':') == 1) ? '0'+ duration : duration);
} else {
if (type == 'Film') {
duration = default_FilmDuration;
} else {
duration = default_Duration;
}
}
var channelId = msg.ChannelId(channelName);
TVprogs.push({"bouquet" : bouquet, "type": type, "channelId" : channelId, "channelName" : channelName, "hourStart" : hourStart, "title" : title, "duration" : duration});
}
});
}
}
});
callback(TVprogs);
} |
Partager