Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lấy danh sách tập cho phim bộ #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ctrls/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ exports.watch = (req, res, next) => {
.then(medias => {
return res.render('watch.html', {
medias,
video: medias[0]
video: medias[0],
episodes: medias[0].episodes
})
})
.catch(console.log)
Expand Down
35 changes: 30 additions & 5 deletions lib/videos/bilutv.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ const _search = (q) => {

// /xem-phim/phim-gai-goi-berlin-3224.html
exports.findMedias = (url) => {
url = url.replace('.html', '')
if (url.indexOf('/phim') !== -1) {
url = url.replace('.html', '')
}

return got(`${DOMAIN}${url}`, gotOptions)
.then(reponse => extractMedia(reponse.body))
.then(playerSetting => playerSetting.sources.map(video => ({
Expand All @@ -66,7 +69,8 @@ exports.findMedias = (url) => {
'thumb': playerSetting.poster,
'url': decodeUrl(video.file, 'bilutv.com' + '4590481877' + playerSetting.modelId),
'resolution': parseFloat(video.label),
'label': video.label
'label': video.label,
'episodes': playerSetting.episodes
})
))
}
Expand All @@ -77,12 +81,33 @@ function extractMedia (body) {
const result = parse(
body.slice(beginSlice, endSlice).trim()
)
let ret = {};

if (result.err) {
return {
ret = {
sources: []
}
};
}
return result.value
ret = result.value;

// parse episodes
let $ = cheerio.load(body);

ret.episodes = [];
$('.list-episode')
.find('a')
.map((idx, elem) => {
let url = $(elem).attr('href').replace(DOMAIN, '');

ret.episodes.push({
no: $(elem).text(),
hash: new Buffer(
aes.enc(provider + '|' + url, process.env.SECRET)
).toString('base64')
});
});

return ret;
}

// decode url using the password
Expand Down
12 changes: 8 additions & 4 deletions lib/videos/phimbathu.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ exports.findMedias = (url) => {
'thumb': playerSetting.poster,
'url': decodeUrl(video.file, 'phimbathu.com' + '4590481877' + playerSetting.modelId),
'resolution': parseFloat(video.label),
'label': video.label
'label': video.label,
'episodes': playerSetting.episodes || []
})
))
}
Expand All @@ -65,14 +66,17 @@ function extractMedia (body) {
const result = parse(
body.slice(beginSlice, endSlice).trim()
)
let ret = {};

if (result.err) {
return {
ret = {
sources: []
}
};
}

return result.value
ret = result.value;

return ret;
}

// decode url using the password
Expand Down
7 changes: 5 additions & 2 deletions public/css/style.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
.container {
max-width: 600px;
max-width: 980px;
text-align: center;
}
.wrapper {
max-width: 600px;
max-width: 980px;
margin: 0 auto;
}
html, button, input, select, textarea,
.pure-g [class *= "pure-u"] {
font-family: monospace;
font-size: 20px;
}
.episodes {
margin-top: 10px;
}

.green {
color: #88B04B;
Expand Down
8 changes: 7 additions & 1 deletion views/watch.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,19 @@ <h3>

<div class="videocontent">
<video poster="{{video.thumb}}" id="phim-clgt-vn" class="video-js vjs-default-skin vjs-16-9 vjs-big-play-centered"
controls width="640" height="auto"
controls width="980" height="auto"
data-setup='{"fluid":true}'>
{{#medias}}
<source src="{{url}}" type="video/mp4" label="{{label}}" res="{{resolution}}" />
{{/medias}}
</video>
</div>

<div class="episodes">
{{#episodes}}
<b><a href="/watch?id={{hash}}">{{no}}</a></b>
{{/episodes}}
</div>
</div>
</section>
</div>
Expand Down