@vime-js/core
Advanced tools
Comparing version 1.4.0 to 1.4.2
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.4.2](https://github.com/vime-js/vime/tree/master/packages/vime-core/compare/v1.4.1...v1.4.2) (2020-04-10) | ||
### Bug Fixes | ||
* rename srcId to mediaId ([6dcaf41](https://github.com/vime-js/vime/tree/master/packages/vime-core/commit/6dcaf41d5ae64ca83f3859f19634a45a24ce84ce)) | ||
# [1.4.0](https://github.com/vime-js/vime/tree/master/packages/vime-core/compare/v1.3.0...v1.4.0) (2020-04-09) | ||
@@ -8,0 +19,0 @@ |
@@ -17,7 +17,7 @@ import { is_string, decode_query_string } from '@vime-js/utils'; | ||
export const fetch_video_info_json = (srcId, fields) => window | ||
.fetch(`${API_ENDPOINT}/video/${srcId}?fields=${fields}`) | ||
export const fetch_video_info_json = (mediaId, fields) => window | ||
.fetch(`${API_ENDPOINT}/video/${mediaId}?fields=${fields}`) | ||
.then((response) => response.json()); | ||
export const extract_src_id = (src) => { | ||
export const extract_media_id = (src) => { | ||
const match = src ? src.match(SRC) : null; | ||
@@ -28,21 +28,21 @@ return match ? match[1] : null; | ||
export const fetch_video_duration = (src) => { | ||
const srcId = extract_src_id(src); | ||
if (!srcId) return Promise.resolve(null); | ||
return fetch_video_info_json(srcId, 'duration').then((data) => data.duration); | ||
const mediaId = extract_media_id(src); | ||
if (!mediaId) return Promise.resolve(null); | ||
return fetch_video_info_json(mediaId, 'duration').then((data) => data.duration); | ||
}; | ||
export const build_embed_url = (src) => { | ||
const srcId = extract_src_id(src); | ||
return srcId ? `${ORIGIN}/embed/video/${srcId}?api=1` : null; | ||
const mediaId = extract_media_id(src); | ||
return mediaId ? `${ORIGIN}/embed/video/${mediaId}?api=1` : null; | ||
}; | ||
export const build_watch_url = (src) => { | ||
const srcId = extract_src_id(src); | ||
return srcId ? `${ORIGIN}/video/${srcId}` : null; | ||
const mediaId = extract_media_id(src); | ||
return mediaId ? `${ORIGIN}/video/${mediaId}` : null; | ||
}; | ||
export const fetch_poster = (src) => { | ||
const srcId = extract_src_id(src); | ||
if (!srcId) return Promise.resolve(null); | ||
return fetch_video_info_json(srcId, 'thumbnail_1080_url').then((data) => data.thumbnail_1080_url); | ||
const mediaId = extract_media_id(src); | ||
if (!mediaId) return Promise.resolve(null); | ||
return fetch_video_info_json(mediaId, 'thumbnail_1080_url').then((data) => data.thumbnail_1080_url); | ||
}; |
{ | ||
"name": "@vime-js/core", | ||
"description": "Vime core", | ||
"version": "1.4.0", | ||
"version": "1.4.2", | ||
"svelte": "src/index.js", | ||
@@ -29,3 +29,3 @@ "module": "src/index.js", | ||
}, | ||
"gitHead": "0ed729d6ead352c8b78e6ac2f423b58fdfdee309" | ||
"gitHead": "5d954f0a2deb3c2d5b72782c8c9246197e04bec5" | ||
} |
10
vimeo.js
@@ -22,3 +22,3 @@ import { is_string, decode_json } from '@vime-js/utils'; | ||
export const extract_src_id = (src) => { | ||
export const extract_media_id = (src) => { | ||
const match = src ? src.match(SRC) : null; | ||
@@ -29,9 +29,9 @@ return match ? match[1] : null; | ||
export const build_embed_url = (src) => { | ||
const srcId = extract_src_id(src); | ||
return `${EMBED_ORIGIN}/video/${srcId || BLANK_SRC_ID}`; | ||
const mediaId = extract_media_id(src); | ||
return `${EMBED_ORIGIN}/video/${mediaId || BLANK_SRC_ID}`; | ||
}; | ||
export const build_watch_url = (src) => { | ||
const srcId = extract_src_id(src); | ||
return srcId ? `${ORIGIN}/${srcId}` : null; | ||
const mediaId = extract_media_id(src); | ||
return mediaId ? `${ORIGIN}/${mediaId}` : null; | ||
}; | ||
@@ -38,0 +38,0 @@ |
@@ -23,3 +23,3 @@ import { is_string, load_image, decode_json } from '@vime-js/utils'; | ||
export const extract_src_id = (src) => { | ||
export const extract_media_id = (src) => { | ||
const match = src ? src.match(SRC) : null; | ||
@@ -30,15 +30,15 @@ return match ? match[1] : null; | ||
export const build_embed_url = (src, cookies) => { | ||
const srcId = extract_src_id(src); | ||
return srcId ? `${build_origin(cookies)}/embed/${srcId}?enablejsapi=1` : null; | ||
const mediaId = extract_media_id(src); | ||
return mediaId ? `${build_origin(cookies)}/embed/${mediaId}?enablejsapi=1` : null; | ||
}; | ||
export const build_watch_url = (src) => { | ||
const srcId = extract_src_id(src); | ||
return srcId ? `${ORIGIN}/watch?v=${srcId}` : null; | ||
const mediaId = extract_media_id(src); | ||
return mediaId ? `${ORIGIN}/watch?v=${mediaId}` : null; | ||
}; | ||
export const fetch_poster = (src) => { | ||
const srcId = extract_src_id(src); | ||
if (!srcId) return Promise.resolve(null); | ||
const posterSrc = (quality) => `https://i.ytimg.com/vi/${srcId}/${quality}.jpg`; | ||
const mediaId = extract_media_id(src); | ||
if (!mediaId) return Promise.resolve(null); | ||
const posterSrc = (quality) => `https://i.ytimg.com/vi/${mediaId}/${quality}.jpg`; | ||
// We are testing a that the image has a min-width of 121px because if the thumbnail does | ||
@@ -45,0 +45,0 @@ // not exist YouTube returns a blank/error image that is 120px wide. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10246