Удачный парсинг фильмов и сериалов с OnlineLife
This commit is contained in:
@@ -41,7 +41,7 @@ public class Onlinelife implements KinoWarez {
|
|||||||
for (Element element : elements) {
|
for (Element element : elements) {
|
||||||
Element childElement = element.child(0);
|
Element childElement = element.child(0);
|
||||||
String name = childElement.text();
|
String name = childElement.text();
|
||||||
String url = childElement.attr("href");
|
String url = "onlinelife/" + (childElement.attr("href").substring(DOMAIN.length()+1));
|
||||||
|
|
||||||
if (strong) {
|
if (strong) {
|
||||||
Matcher matcher = pattern.matcher(name.toLowerCase());
|
Matcher matcher = pattern.matcher(name.toLowerCase());
|
||||||
@@ -68,11 +68,12 @@ public class Onlinelife implements KinoWarez {
|
|||||||
JsonObject jsonObj = new Gson().fromJson(json, JsonObject.class);
|
JsonObject jsonObj = new Gson().fromJson(json, JsonObject.class);
|
||||||
|
|
||||||
if (jsonObj.has("file")) {
|
if (jsonObj.has("file")) {
|
||||||
return jsonObj.get("file").getAsString();
|
return "{\"file\":\"" + jsonObj.get("file").getAsString() + "\"}";
|
||||||
} else if (jsonObj.has("pl")) {
|
} else if (jsonObj.has("pl")) {
|
||||||
return jsonObj.get("pl").getAsString();
|
browser.setEncoding("utf-8");
|
||||||
|
return browser.get(jsonObj.get("pl").getAsString());
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "{}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,8 +38,8 @@ public class PlayerServlet extends HttpServlet {
|
|||||||
req.getPathInfo(), req.getServletPath()));
|
req.getPathInfo(), req.getServletPath()));
|
||||||
|
|
||||||
KinoWarez kinoWarez = new Onlinelife();
|
KinoWarez kinoWarez = new Onlinelife();
|
||||||
String movie_url = kinoWarez.player(req.getPathInfo());
|
String json = kinoWarez.player(req.getPathInfo());
|
||||||
model.put("movie_url", movie_url);
|
model.put("json", json);
|
||||||
|
|
||||||
resp.setCharacterEncoding("UTF-8");
|
resp.setCharacterEncoding("UTF-8");
|
||||||
resp.setContentType("text/html;charset=UTF-8");
|
resp.setContentType("text/html;charset=UTF-8");
|
||||||
|
|||||||
@@ -1,3 +1,66 @@
|
|||||||
<#include "/header.inc.html">
|
<#include "/header.inc.html">
|
||||||
<video id="player" src="${movie_url}" class="center-block" controls="controls"></video>
|
<script type="text/javascript">
|
||||||
|
var video_data = ${json};
|
||||||
|
|
||||||
|
$(function(){
|
||||||
|
if (typeof(video_data.file) !== 'undefined') {
|
||||||
|
$('#player').attr('src', video_data.file);
|
||||||
|
} else if (typeof(video_data.playlist) !== 'undefined') {
|
||||||
|
$('#pl-season').removeClass('hide');
|
||||||
|
menu = $('#pl-season-menu');
|
||||||
|
|
||||||
|
menu.html('');
|
||||||
|
video_data.playlist.forEach(function(item, i){
|
||||||
|
menu.append('<li><a data-tag="' + i + '" href="#" onclick="return false;">' + item.comment + '</a></li>');
|
||||||
|
});
|
||||||
|
|
||||||
|
ddBtn = $('#dropdownSeason');
|
||||||
|
smenu = $('#pl-serial-menu');
|
||||||
|
menu.find('a').bind('click', function(){
|
||||||
|
ddBtn.html(this.text + ' <span class="caret"></span>');
|
||||||
|
|
||||||
|
$('#dropdownSerial').html('Serials <span class="caret"></span>');
|
||||||
|
|
||||||
|
smenu.html('');
|
||||||
|
video_data.playlist[this.attributes['data-tag'].value].playlist.forEach(function(item){
|
||||||
|
smenu.append('<li><a data-file="' + item.file + '" href="#" onclick="return false;">' + item.comment + '</a></li>');
|
||||||
|
});
|
||||||
|
|
||||||
|
smenu.find('a').bind('click', function(){
|
||||||
|
$('#dropdownSerial').html(this.text + ' <span class="caret"></span>');
|
||||||
|
$('#player').attr('src', this.attributes['data-file'].value);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#pl-serial').removeClass('hide');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div id="pl-season" class="dropdown hide" style="display: inline-block;">
|
||||||
|
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownSeason" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||||
|
Seasons
|
||||||
|
<span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul id="pl-season-menu" class="dropdown-menu" aria-labelledby="dropdownSeason">
|
||||||
|
<li><a href="#">Season</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="pl-serial" class="dropdown hide" style="display: inline-block;">
|
||||||
|
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownSerial" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
|
||||||
|
Serials
|
||||||
|
<span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul id="pl-serial-menu" class="dropdown-menu" aria-labelledby="dropdownSerial">
|
||||||
|
<li><a href="#">Serial</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br><br>
|
||||||
|
|
||||||
|
<video id="player" class="center-block" controls="controls"></video>
|
||||||
|
<br>
|
||||||
<#include "/fother.inc.html">
|
<#include "/fother.inc.html">
|
||||||
Reference in New Issue
Block a user