Skip to content

Commit

Permalink
develop parser vmedia
Browse files Browse the repository at this point in the history
  • Loading branch information
nthu31 committed May 23, 2024
1 parent 9445531 commit 6f11248
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 0 deletions.
14 changes: 14 additions & 0 deletions vmedia/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"longname": "Vision Media",
"name": "vmedia",
"describe": "Recognizes the accesses to the platform Vision Media",
"contact": "Sean Duffy, Violita Kovchegov",
"pkb": false,
"docurl": "http://analyses.ezpaarse.org/platforms/650c844a484adaf4809270f5",
"domains": [
"cgust.app.visionmedia.com.tw",
"ntust.app.visionmedia.com.tw"
],
"version": "2024-05-23",
"status": "beta"
}
54 changes: 54 additions & 0 deletions vmedia/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/usr/bin/env node

'use strict';
const Parser = require('../.lib/parser.js');

/**
* Recognizes the accesses to the platform Vision Media
* @param {Object} parsedUrl an object representing the URL to analyze
* main attributes: pathname, query, hostname
* @param {Object} ec an object representing the EC whose URL is being analyzed
* @return {Object} the result
*/
module.exports = new Parser(function analyseEC(parsedUrl, ec) {
let result = {};
let path = parsedUrl.pathname;
// uncomment this line if you need parameters
let param = parsedUrl.query || {};

// use console.error for debuging
// console.error(parsedUrl);

let match;

if (/^\/video\/search$/i.test(path)) {
// https://cgust.app.visionmedia.com.tw/video/search?q=最新電影
// https://cgust.app.visionmedia.com.tw/video/search?q=美味午餐大作戰
// https://ntust.app.visionmedia.com.tw/video/search?q=最新電影
// https://ntust.app.visionmedia.com.tw/video/search?q=美味午餐大作戰
result.rtype = 'SEARCH';
result.mime = 'HTML';

} else if ((match = /^\/video\/detail\/(trailer|movie)\/([a-zA-Z0-9-]+)$/i.exec(path)) !== null) {
// https://ntust.app.visionmedia.com.tw/video/detail/trailer/48a6dfd6-8723-4d26-9005-d9a2ac678c5d
// https://cgust.app.visionmedia.com.tw/video/detail/trailer/feda4692-8aa5-4ac6-b33c-5c744482befb
// https://cgust.app.visionmedia.com.tw/video/detail/movie/feda4692-8aa5-4ac6-b33c-5c744482befb
// https://ntust.app.visionmedia.com.tw/video/detail/movie/70ce40f9-04b2-4a07-a56a-a99beb2b5694
result.rtype = 'VIDEO';
result.mime = 'MISC';
result.unitid = match[2];

} else if (/^\/video\/list$/i.test(path) && param.tag_name !== undefined) {
// https://ntust.app.visionmedia.com.tw/video/list?tag_name=科幻奇幻
// https://ntust.app.visionmedia.com.tw/video/list?tag_name=科幻奇幻&tag_name=西班牙語
// https://cgust.app.visionmedia.com.tw/video/list?tag_name=西班牙語
let isArray = Array.isArray(param.tag_name);
result.rtype = 'TOC';
result.mime = 'HTML';
if (isArray) result.unitid = param.tag_name[param.tag_name.length-1];
else result.unitid = param.tag_name;

}

return result;
});
12 changes: 12 additions & 0 deletions vmedia/test/vmedia.2024-05-23.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
out-unitid;out-rtype;out-mime;in-url
;SEARCH;HTML;https://cgust.app.visionmedia.com.tw/video/search?q=最新電影
;SEARCH;HTML;https://cgust.app.visionmedia.com.tw/video/search?q=美味午餐大作戰
;SEARCH;HTML;https://ntust.app.visionmedia.com.tw/video/search?q=最新電影
;SEARCH;HTML;https://ntust.app.visionmedia.com.tw/video/search?q=美味午餐大作戰
48a6dfd6-8723-4d26-9005-d9a2ac678c5d;VIDEO;MISC;https://ntust.app.visionmedia.com.tw/video/detail/trailer/48a6dfd6-8723-4d26-9005-d9a2ac678c5d
feda4692-8aa5-4ac6-b33c-5c744482befb;VIDEO;MISC;https://cgust.app.visionmedia.com.tw/video/detail/trailer/feda4692-8aa5-4ac6-b33c-5c744482befb
feda4692-8aa5-4ac6-b33c-5c744482befb;VIDEO;MISC;https://cgust.app.visionmedia.com.tw/video/detail/movie/feda4692-8aa5-4ac6-b33c-5c744482befb
70ce40f9-04b2-4a07-a56a-a99beb2b5694;VIDEO;MISC;https://ntust.app.visionmedia.com.tw/video/detail/movie/70ce40f9-04b2-4a07-a56a-a99beb2b5694
科幻奇幻;TOC;HTML;https://ntust.app.visionmedia.com.tw/video/list?tag_name=科幻奇幻
西班牙語;TOC;HTML;https://ntust.app.visionmedia.com.tw/video/list?tag_name=科幻奇幻&tag_name=西班牙語
西班牙語;TOC;HTML;https://cgust.app.visionmedia.com.tw/video/list?tag_name=西班牙語

0 comments on commit 6f11248

Please sign in to comment.