fix parsing ugc.fr (new website)
This commit is contained in:
116
script/ugc.js
116
script/ugc.js
@@ -1,7 +1,7 @@
|
||||
function Film(oSettings)
|
||||
{
|
||||
var self = this;
|
||||
this.consts = {'ugc_url':'http://www.ugc.fr/', 'process_url':'index.php'};
|
||||
this.consts = {'ugc_url':'https://ugc.fr/', 'process_url':'index.php'};
|
||||
this.settings = oSettings;
|
||||
this._attr = {};
|
||||
this._anchor = {};
|
||||
@@ -46,17 +46,19 @@ function Film(oSettings)
|
||||
return this.attr('poster', sPoster);
|
||||
};
|
||||
|
||||
this.backgroundPoster = function(sPoster)
|
||||
this.backgroundPoster = function(sPoster, bForce)
|
||||
{
|
||||
if(sPoster) sPoster = this.getPosterUrl(sPoster, 'medium');
|
||||
bForce = bForce || false;
|
||||
if(sPoster) sPoster = this.getPosterUrl(sPoster, 'large', bForce);
|
||||
return this.attr('poster_bg', sPoster);
|
||||
};
|
||||
|
||||
this.getPosterUrl = function(sUrl, sSize)
|
||||
this.getPosterUrl = function(sUrl, sSize, bForce)
|
||||
{
|
||||
bForce = bForce || false;
|
||||
var sExt = sUrl.substr(sUrl.lastIndexOf('.')+1).toLowerCase();
|
||||
if(sExt=='jpg') sExt = 'jpeg';
|
||||
return this.consts.process_url+'?a=get_poster&type='+sExt+'&data[id]='+this.id()+'&data[url]='+encodeURIComponent(sUrl)+'&data[size]='+sSize;
|
||||
return this.consts.process_url+'?a=get_poster&type='+sExt+'&data[id]='+this.id()+'&data[url]='+encodeURIComponent(sUrl)+'&data[size]='+sSize+'&data[force]='+(bForce?'1':'0');
|
||||
};
|
||||
|
||||
this.edito = function(sEdito)
|
||||
@@ -70,6 +72,11 @@ function Film(oSettings)
|
||||
return this.attr('trailer', sTrailer);
|
||||
};
|
||||
|
||||
this.director = function(sDirector)
|
||||
{
|
||||
return this.attr('director', sDirector);
|
||||
};
|
||||
|
||||
this.attr = function(sName, sValue)
|
||||
{
|
||||
if(!sValue) return this._attr[sName];
|
||||
@@ -118,7 +125,7 @@ function Film(oSettings)
|
||||
.append($('<img>', {'class':'poster', 'src':this.backgroundPoster()})
|
||||
.click(function(){
|
||||
var $This = $(this);
|
||||
var sForceLink = $This.attr('src')+'&data[force]=1';
|
||||
var sForceLink = this.backgroundPoster(this.backgroundPoster(), true);
|
||||
$This.add($This.parent().prev()).attr('src', sForceLink);
|
||||
})))
|
||||
.append($('<div>', {'class':'info'})
|
||||
@@ -129,10 +136,13 @@ function Film(oSettings)
|
||||
.append($('<p>', {'class':'edito'+(!this.edito()?' hide':'')})
|
||||
.append($('<i>', {'class':'fa fa-fw inline fa-edito'}))
|
||||
.append($('<span>').text(this.edito())))
|
||||
.append($('<p>', {'class':'trailer'})
|
||||
/*.append($('<p>', {'class':'trailer'})
|
||||
.append($('<a>', {'target':'_blank', 'href':this.trailer()})
|
||||
.append($('<i>', {'class':'fa fa-fw inline fa-trailer'}))
|
||||
.append('Trailer')))
|
||||
.append('Trailer')))*/
|
||||
.append($('<p>', {'class':'director'})
|
||||
.append($('<i>', {'class':'fa fa-fw inline fa-director'}))
|
||||
.append(this.director()))
|
||||
.append($('<div>', {'class':'timetable'})))
|
||||
//.append($('<div>', {'class':'timetable fa fa-fw fa-spinner fa-spin'})))
|
||||
.hide()
|
||||
@@ -227,11 +237,11 @@ function Ugc()
|
||||
|
||||
//Load cinemas
|
||||
$.each(this.settings.cinemas(), function(iCinemaId, sCinemaName){
|
||||
getUgcPage( 'filmsAjaxAction!getFilmsForPageCinema.action',
|
||||
{cinemaId:iCinemaId, cinemaCode:'', page:'7', filmId:'', filmId_widget:'', '_':Date.now()},
|
||||
function(hDom){self.addCinema(iCinemaId, hDom)},
|
||||
function(){},
|
||||
'html');
|
||||
getUgcPage( 'showingsCinemaAjaxAction!getShowingsForCinemaPage.action',
|
||||
{cinemaId:iCinemaId, date:self.settings.date('french'), page:'10007', sort:'all'},
|
||||
function(hDom){self.addCinema(iCinemaId, hDom)},
|
||||
function(){},
|
||||
'html');
|
||||
});
|
||||
};
|
||||
|
||||
@@ -354,14 +364,13 @@ function Ugc()
|
||||
|
||||
this.addCinema = function(iCinemaId, hDom)
|
||||
{
|
||||
var $Page = $(hDom);
|
||||
var $Films = $Page.find('.FilmDiv');
|
||||
var $Films = $('<div>'+hDom+'</div>').find('.cinema-time-item');
|
||||
this.wip($Films.length);
|
||||
this.addCineNav(iCinemaId);
|
||||
$Films.each(function()
|
||||
{
|
||||
var $Film = $(this);
|
||||
var iFilmId = $Film.find('input[name="filmId"]').val();
|
||||
var iFilmId = $Film.find('.movie-link').attr('href').split('id=').pop();
|
||||
var oFilm = self.film(iFilmId);
|
||||
|
||||
if(!oFilm)
|
||||
@@ -372,19 +381,25 @@ function Ugc()
|
||||
oFilm.id(iFilmId);
|
||||
|
||||
//Edito
|
||||
var sEdito = $.trim($Film.find('.FilmEditorial').text());
|
||||
var sProg = $.trim($Film.find('.programming').text());
|
||||
var sLabel = $.trim($Film.find('.label-ugc').text());
|
||||
var sEdito = sProg?sProg:sLabel;
|
||||
oFilm.edito(sEdito);
|
||||
|
||||
|
||||
//Name
|
||||
oFilm.safe(oFilm.name($Film.find('.FilmTitle').text()));
|
||||
oFilm.safe(oFilm.name($Film.find('.title > a').text()));
|
||||
|
||||
//Poster
|
||||
var sPosterUrl = $Film.find('.FilmThumbnail img').attr('source');
|
||||
https://www.ugc.fr/dynamique/films/57/11757/fr/poster/small/107472_white.jpg
|
||||
var sPosterUrl = $Film.find('.movie-img').attr('source').replace('palegrey.jpg', 'white.jpg');
|
||||
oFilm.poster(sPosterUrl);
|
||||
oFilm.backgroundPoster(sPosterUrl.replace('152x217/FFFFFF', '274x410/EEEEE8'));
|
||||
oFilm.backgroundPoster(sPosterUrl.replace('/small/', '/large/'));
|
||||
|
||||
//Trailer
|
||||
oFilm.trailer($Film.find('.FilmIntroLink a').attr('href'));
|
||||
oFilm.trailer('');
|
||||
|
||||
//Director
|
||||
oFilm.director($.trim($Film.find('.movie-realisator').text().replace('De', ''))); //omg
|
||||
|
||||
//Minimum info acquired: book place on DOM
|
||||
oFilm.anchor();
|
||||
@@ -399,35 +414,30 @@ function Ugc()
|
||||
//Timetable
|
||||
if(!oFilm.ban().status)
|
||||
{
|
||||
getUgcPage( 'filmsAfficheAction!reloadSeancesList.action',
|
||||
{filmId:oFilm.id(), cinemaId:iCinemaId, cinemaCode:'', day:self.settings.date('midnight_timestamp')},
|
||||
function(hData){
|
||||
var sLang = '';
|
||||
var $Timetable = $(hData);
|
||||
var oTimes = [];
|
||||
$Timetable.children().each(function(iKey, oDiv){
|
||||
$Div = $(oDiv);
|
||||
if($Div.attr('class')=='Line') //New Lang
|
||||
{
|
||||
sLang = $.trim($Div.find('.FilmTitle').text());
|
||||
}
|
||||
else if($Div.find('a').length > 0)
|
||||
{
|
||||
$Div.find('a').each(function(iKey, oLink){
|
||||
var $Time = $(oLink);
|
||||
oTime = {'time':$.trim($Time.find('span').text()), 'booking':oFilm.consts.ugc_url+$Time.attr('href')};
|
||||
oFilm.timetable(iCinemaId, sLang, oTime);
|
||||
});
|
||||
}
|
||||
});
|
||||
oFilm.renderTimetable(iCinemaId);
|
||||
self.wip(-1);
|
||||
},
|
||||
function(){
|
||||
self.wip(-1);
|
||||
self.error('Ajax Error detected on movie "'+oFilm.name()+'" @'+self.settings.cinemas(iCinemaId)+'.');
|
||||
},
|
||||
'html');
|
||||
var sLang = '';
|
||||
var $Timetables = $Film.find('ul.timetable');
|
||||
var oTimes = [];
|
||||
|
||||
//Loop on languages
|
||||
$Timetables.each(function(iKey, oTimeTable){
|
||||
|
||||
//Loop on sessions
|
||||
$(oTimeTable).find('li').each(function(iKey, oLi){
|
||||
$Li = $(oLi);
|
||||
if($Li.attr('class')=='movie-version')
|
||||
{
|
||||
sLang = $.trim($Li.text());
|
||||
}
|
||||
else if($Li.find('a').length > 0)
|
||||
{
|
||||
var $Time = $Li.find('a');
|
||||
oTime = {'time':$.trim($Time.text()), 'booking':oFilm.consts.ugc_url+$Time.attr('href')};
|
||||
oFilm.timetable(iCinemaId, sLang, oTime);
|
||||
}
|
||||
});
|
||||
});
|
||||
oFilm.renderTimetable(iCinemaId);
|
||||
self.wip(-1);
|
||||
}
|
||||
else self.wip(-1);
|
||||
});
|
||||
@@ -487,7 +497,7 @@ function Settings()
|
||||
this.cinemas(asCookieCinemas?asCookieCinemas:{'10':'Les Halles', '12':'Bercy', '20':'La Défense'});
|
||||
|
||||
//UGC cinemas
|
||||
getUgcPage( 'headerReservationAction!reloadCinemasList.action',
|
||||
getUgcPage( 'resaExpressAction!getCinemaList.action',
|
||||
{'regionsAndCinemasBean.region':'', 'regionsAndCinemasBean.cinema':'', '_':this.date('timestamp')},
|
||||
function(jData){
|
||||
self.ugcCinemas(jData.cinemas);
|
||||
@@ -551,6 +561,8 @@ function Settings()
|
||||
return this._date.getFullYear();
|
||||
case 'html':
|
||||
return this.date('year')+'-'+(("0" + (this.date('month') + 1)).slice(-2))+'-'+(("0" + this.date('day')).slice(-2));
|
||||
case 'french':
|
||||
return (("0" + this.date('day')).slice(-2))+'/'+(("0" + (this.date('month') + 1)).slice(-2))+'/'+this.date('year');
|
||||
case 'formal':
|
||||
return this.consts.days[this.date('weekday')]+', '+this.consts.months[this.date('month')]+' '+this.date('day');
|
||||
case 'abbr':
|
||||
|
||||
Reference in New Issue
Block a user