fix parsing ugc.fr (new website)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,4 +4,5 @@
|
|||||||
/build.xml
|
/build.xml
|
||||||
/.externalToolBuilders/
|
/.externalToolBuilders/
|
||||||
/.sass-cache/
|
/.sass-cache/
|
||||||
|
/style/.sass-cache/
|
||||||
/tmp/
|
/tmp/
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
require_once 'settings.php';
|
require_once 'settings.php';
|
||||||
|
|
||||||
define('TMP_FOLDER', 'tmp/');
|
define('TMP_FOLDER', 'tmp/');
|
||||||
|
define('UGC_URL', 'https://ugc.fr');
|
||||||
|
|
||||||
function getPage($sPath, $asVars, $sType)
|
function getPage($sPath, $asVars, $sType)
|
||||||
{
|
{
|
||||||
@@ -15,12 +16,14 @@ function getPage($sPath, $asVars, $sType)
|
|||||||
}
|
}
|
||||||
if(!$bSavePage || !file_exists($sFileName) || date('dmY', filemtime($sFileName))!=date('dmY'))
|
if(!$bSavePage || !file_exists($sFileName) || date('dmY', filemtime($sFileName))!=date('dmY'))
|
||||||
{
|
{
|
||||||
$sUrl = 'http://www.ugc.fr/'.$sPath.'?'.http_build_query($asVars);
|
$sUrl = UGC_URL.'/'.$sPath.'?'.http_build_query($asVars);
|
||||||
$oCurl = curl_init();
|
$oCurl = curl_init();
|
||||||
curl_setopt($oCurl, CURLOPT_URL, $sUrl);
|
curl_setopt($oCurl, CURLOPT_URL, $sUrl);
|
||||||
curl_setopt($oCurl, CURLOPT_HEADER, false);
|
curl_setopt($oCurl, CURLOPT_HEADER, false);
|
||||||
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($oCurl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
curl_setopt($oCurl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
||||||
|
curl_setopt($oCurl, CURLOPT_REFERER, UGC_URL.'/homepage.html');
|
||||||
|
|
||||||
$sContent = curl_exec($oCurl);
|
$sContent = curl_exec($oCurl);
|
||||||
curl_close($oCurl);
|
curl_close($oCurl);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
function Film(oSettings)
|
function Film(oSettings)
|
||||||
{
|
{
|
||||||
var self = this;
|
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.settings = oSettings;
|
||||||
this._attr = {};
|
this._attr = {};
|
||||||
this._anchor = {};
|
this._anchor = {};
|
||||||
@@ -46,17 +46,19 @@ function Film(oSettings)
|
|||||||
return this.attr('poster', sPoster);
|
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);
|
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();
|
var sExt = sUrl.substr(sUrl.lastIndexOf('.')+1).toLowerCase();
|
||||||
if(sExt=='jpg') sExt = 'jpeg';
|
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)
|
this.edito = function(sEdito)
|
||||||
@@ -70,6 +72,11 @@ function Film(oSettings)
|
|||||||
return this.attr('trailer', sTrailer);
|
return this.attr('trailer', sTrailer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.director = function(sDirector)
|
||||||
|
{
|
||||||
|
return this.attr('director', sDirector);
|
||||||
|
};
|
||||||
|
|
||||||
this.attr = function(sName, sValue)
|
this.attr = function(sName, sValue)
|
||||||
{
|
{
|
||||||
if(!sValue) return this._attr[sName];
|
if(!sValue) return this._attr[sName];
|
||||||
@@ -118,7 +125,7 @@ function Film(oSettings)
|
|||||||
.append($('<img>', {'class':'poster', 'src':this.backgroundPoster()})
|
.append($('<img>', {'class':'poster', 'src':this.backgroundPoster()})
|
||||||
.click(function(){
|
.click(function(){
|
||||||
var $This = $(this);
|
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);
|
$This.add($This.parent().prev()).attr('src', sForceLink);
|
||||||
})))
|
})))
|
||||||
.append($('<div>', {'class':'info'})
|
.append($('<div>', {'class':'info'})
|
||||||
@@ -129,10 +136,13 @@ function Film(oSettings)
|
|||||||
.append($('<p>', {'class':'edito'+(!this.edito()?' hide':'')})
|
.append($('<p>', {'class':'edito'+(!this.edito()?' hide':'')})
|
||||||
.append($('<i>', {'class':'fa fa-fw inline fa-edito'}))
|
.append($('<i>', {'class':'fa fa-fw inline fa-edito'}))
|
||||||
.append($('<span>').text(this.edito())))
|
.append($('<span>').text(this.edito())))
|
||||||
.append($('<p>', {'class':'trailer'})
|
/*.append($('<p>', {'class':'trailer'})
|
||||||
.append($('<a>', {'target':'_blank', 'href':this.trailer()})
|
.append($('<a>', {'target':'_blank', 'href':this.trailer()})
|
||||||
.append($('<i>', {'class':'fa fa-fw inline fa-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'})))
|
||||||
//.append($('<div>', {'class':'timetable fa fa-fw fa-spinner fa-spin'})))
|
//.append($('<div>', {'class':'timetable fa fa-fw fa-spinner fa-spin'})))
|
||||||
.hide()
|
.hide()
|
||||||
@@ -227,8 +237,8 @@ function Ugc()
|
|||||||
|
|
||||||
//Load cinemas
|
//Load cinemas
|
||||||
$.each(this.settings.cinemas(), function(iCinemaId, sCinemaName){
|
$.each(this.settings.cinemas(), function(iCinemaId, sCinemaName){
|
||||||
getUgcPage( 'filmsAjaxAction!getFilmsForPageCinema.action',
|
getUgcPage( 'showingsCinemaAjaxAction!getShowingsForCinemaPage.action',
|
||||||
{cinemaId:iCinemaId, cinemaCode:'', page:'7', filmId:'', filmId_widget:'', '_':Date.now()},
|
{cinemaId:iCinemaId, date:self.settings.date('french'), page:'10007', sort:'all'},
|
||||||
function(hDom){self.addCinema(iCinemaId, hDom)},
|
function(hDom){self.addCinema(iCinemaId, hDom)},
|
||||||
function(){},
|
function(){},
|
||||||
'html');
|
'html');
|
||||||
@@ -354,14 +364,13 @@ function Ugc()
|
|||||||
|
|
||||||
this.addCinema = function(iCinemaId, hDom)
|
this.addCinema = function(iCinemaId, hDom)
|
||||||
{
|
{
|
||||||
var $Page = $(hDom);
|
var $Films = $('<div>'+hDom+'</div>').find('.cinema-time-item');
|
||||||
var $Films = $Page.find('.FilmDiv');
|
|
||||||
this.wip($Films.length);
|
this.wip($Films.length);
|
||||||
this.addCineNav(iCinemaId);
|
this.addCineNav(iCinemaId);
|
||||||
$Films.each(function()
|
$Films.each(function()
|
||||||
{
|
{
|
||||||
var $Film = $(this);
|
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);
|
var oFilm = self.film(iFilmId);
|
||||||
|
|
||||||
if(!oFilm)
|
if(!oFilm)
|
||||||
@@ -372,19 +381,25 @@ function Ugc()
|
|||||||
oFilm.id(iFilmId);
|
oFilm.id(iFilmId);
|
||||||
|
|
||||||
//Edito
|
//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);
|
oFilm.edito(sEdito);
|
||||||
|
|
||||||
//Name
|
//Name
|
||||||
oFilm.safe(oFilm.name($Film.find('.FilmTitle').text()));
|
oFilm.safe(oFilm.name($Film.find('.title > a').text()));
|
||||||
|
|
||||||
//Poster
|
//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.poster(sPosterUrl);
|
||||||
oFilm.backgroundPoster(sPosterUrl.replace('152x217/FFFFFF', '274x410/EEEEE8'));
|
oFilm.backgroundPoster(sPosterUrl.replace('/small/', '/large/'));
|
||||||
|
|
||||||
//Trailer
|
//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
|
//Minimum info acquired: book place on DOM
|
||||||
oFilm.anchor();
|
oFilm.anchor();
|
||||||
@@ -399,35 +414,30 @@ function Ugc()
|
|||||||
//Timetable
|
//Timetable
|
||||||
if(!oFilm.ban().status)
|
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 sLang = '';
|
||||||
var $Timetable = $(hData);
|
var $Timetables = $Film.find('ul.timetable');
|
||||||
var oTimes = [];
|
var oTimes = [];
|
||||||
$Timetable.children().each(function(iKey, oDiv){
|
|
||||||
$Div = $(oDiv);
|
//Loop on languages
|
||||||
if($Div.attr('class')=='Line') //New Lang
|
$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($Div.find('.FilmTitle').text());
|
sLang = $.trim($Li.text());
|
||||||
}
|
}
|
||||||
else if($Div.find('a').length > 0)
|
else if($Li.find('a').length > 0)
|
||||||
{
|
{
|
||||||
$Div.find('a').each(function(iKey, oLink){
|
var $Time = $Li.find('a');
|
||||||
var $Time = $(oLink);
|
oTime = {'time':$.trim($Time.text()), 'booking':oFilm.consts.ugc_url+$Time.attr('href')};
|
||||||
oTime = {'time':$.trim($Time.find('span').text()), 'booking':oFilm.consts.ugc_url+$Time.attr('href')};
|
|
||||||
oFilm.timetable(iCinemaId, sLang, oTime);
|
oFilm.timetable(iCinemaId, sLang, oTime);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
oFilm.renderTimetable(iCinemaId);
|
oFilm.renderTimetable(iCinemaId);
|
||||||
self.wip(-1);
|
self.wip(-1);
|
||||||
},
|
|
||||||
function(){
|
|
||||||
self.wip(-1);
|
|
||||||
self.error('Ajax Error detected on movie "'+oFilm.name()+'" @'+self.settings.cinemas(iCinemaId)+'.');
|
|
||||||
},
|
|
||||||
'html');
|
|
||||||
}
|
}
|
||||||
else 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'});
|
this.cinemas(asCookieCinemas?asCookieCinemas:{'10':'Les Halles', '12':'Bercy', '20':'La Défense'});
|
||||||
|
|
||||||
//UGC cinemas
|
//UGC cinemas
|
||||||
getUgcPage( 'headerReservationAction!reloadCinemasList.action',
|
getUgcPage( 'resaExpressAction!getCinemaList.action',
|
||||||
{'regionsAndCinemasBean.region':'', 'regionsAndCinemasBean.cinema':'', '_':this.date('timestamp')},
|
{'regionsAndCinemasBean.region':'', 'regionsAndCinemasBean.cinema':'', '_':this.date('timestamp')},
|
||||||
function(jData){
|
function(jData){
|
||||||
self.ugcCinemas(jData.cinemas);
|
self.ugcCinemas(jData.cinemas);
|
||||||
@@ -551,6 +561,8 @@ function Settings()
|
|||||||
return this._date.getFullYear();
|
return this._date.getFullYear();
|
||||||
case 'html':
|
case 'html':
|
||||||
return this.date('year')+'-'+(("0" + (this.date('month') + 1)).slice(-2))+'-'+(("0" + this.date('day')).slice(-2));
|
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':
|
case 'formal':
|
||||||
return this.consts.days[this.date('weekday')]+', '+this.consts.months[this.date('month')]+' '+this.date('day');
|
return this.consts.days[this.date('weekday')]+', '+this.consts.months[this.date('month')]+' '+this.date('day');
|
||||||
case 'abbr':
|
case 'abbr':
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -86,6 +86,9 @@ select {
|
|||||||
.fa-trailer:before {
|
.fa-trailer:before {
|
||||||
content: "\f144";
|
content: "\f144";
|
||||||
}
|
}
|
||||||
|
.fa-director:before {
|
||||||
|
content: "\f007";
|
||||||
|
}
|
||||||
.fa-spinner {
|
.fa-spinner {
|
||||||
color:#08288B;
|
color:#08288B;
|
||||||
font-size:2em;
|
font-size:2em;
|
||||||
@@ -265,8 +268,8 @@ main {
|
|||||||
color:#777;
|
color:#777;
|
||||||
}
|
}
|
||||||
|
|
||||||
.film .trailer {
|
.film .director {
|
||||||
|
color: #555;
|
||||||
}
|
}
|
||||||
|
|
||||||
.film .timetable {
|
.film .timetable {
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 23 KiB |
Reference in New Issue
Block a user