Started work on dailymotion implementation. Looks like HLS player will be required for this.

This commit is contained in:
rainbow napkin 2025-05-06 23:35:12 -04:00
parent 2a3740dece
commit 336c746ba7
3 changed files with 33 additions and 8 deletions

View file

@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
//NPM Imports
const url = require("node:url");
//const url = require("node:url");
const validator = require('validator');//No express here, so regular validator it is!
//local import
@ -32,7 +32,11 @@ module.exports.yankMedia = async function(url, title){
//return media object list from IA module
return await iaUtil.fetchMetadata(pullType.id, title);
case "yt":
//return mediao object list from the YT-DLP module's youtube function
return await ytdlpUtil.fetchYoutubeVideoMetadata(pullType.id, title);
case "dm":
//return mediao object list from the YT-DLP module's dailymotion function
return await ytdlpUtil.fetchDailymotionMetadata(pullType.id, title);
default:
//return null to signify a bad url
return null;
@ -43,8 +47,9 @@ module.exports.refreshRawLink = async function(mediaObj){
switch(mediaObj.type){
case 'yt':
//Scrape expiration from query strings
//const expires = mediaObj.rawLink.match(/expire=([0-9]+)/); //Keeping this regex version I wrote at first in-case we need the speed
const expires = new URL(mediaObj.rawLink).searchParams.get("expire");
const expires = mediaObj.rawLink.match(/expire=([0-9]+)/);
//Went with regex for speed, but I figure I'd keep this around in case we want the accuracy of a battle-tested implementation
//const expires = new URL(mediaObj.rawLink).searchParams.get("expire");
//If we have a valid raw file link that will be good by the end of the video
if(expires != null && (expires * 1000) > mediaObj.getEndTime()){
@ -96,6 +101,14 @@ module.exports.getMediaType = async function(url){
}
}
//If we have a match to a dailymotion video
if(match = url.match(/dailymotion\.com\/video\/([a-z0-9]{7})/)){
return {
type: "dm",
id: match[1]
}
}
//If we fell through all of our media types without a match
return{
type: null,