From 6f112482388337c7dd3503749f4ffa0cf6754cb1 Mon Sep 17 00:00:00 2001 From: Wayne Date: Thu, 23 May 2024 11:06:35 +0800 Subject: [PATCH] develop parser vmedia --- vmedia/manifest.json | 14 ++++++++ vmedia/parser.js | 54 +++++++++++++++++++++++++++++++ vmedia/test/vmedia.2024-05-23.csv | 12 +++++++ 3 files changed, 80 insertions(+) create mode 100644 vmedia/manifest.json create mode 100755 vmedia/parser.js create mode 100644 vmedia/test/vmedia.2024-05-23.csv diff --git a/vmedia/manifest.json b/vmedia/manifest.json new file mode 100644 index 00000000..0465b1cb --- /dev/null +++ b/vmedia/manifest.json @@ -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" +} \ No newline at end of file diff --git a/vmedia/parser.js b/vmedia/parser.js new file mode 100755 index 00000000..f05e44e2 --- /dev/null +++ b/vmedia/parser.js @@ -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; +}); diff --git a/vmedia/test/vmedia.2024-05-23.csv b/vmedia/test/vmedia.2024-05-23.csv new file mode 100644 index 00000000..9b41872f --- /dev/null +++ b/vmedia/test/vmedia.2024-05-23.csv @@ -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=西班牙語 \ No newline at end of file