Mholloway has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/392979 )
Change subject: Media: move extmetadata properties of interest into the top
level
......................................................................
Media: move extmetadata properties of interest into the top level
Includes Artist, Credit, LicenseShortName, LicenseUrl, and
ImageDescription in the top level of each item (as artist, credit,
license, license_url, and description). Discards the remaining properties.
Bug: T177430
Change-Id: Ic625f7c8a219be7d35a32d468b80781045570f4f
---
M lib/media.js
M spec.yaml
2 files changed, 25 insertions(+), 16 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps
refs/changes/79/392979/1
diff --git a/lib/media.js b/lib/media.js
index f454963..cc237a0 100644
--- a/lib/media.js
+++ b/lib/media.js
@@ -37,14 +37,6 @@
}
}
-function getExtMetadataValues(extmetadata) {
- const ext = {};
- Object.keys(extmetadata).forEach((key) => {
- ext[key] = extmetadata[key].value;
- });
- return ext;
-}
-
/**
* Get file page titles from a NodeList of media elements from Parsoid HTML
* @param {!NodeList} selection NodeList containing media items from Parsoid
HTML
@@ -90,7 +82,8 @@
function makeResults(items) {
return items.map((item) => {
const info = item.videoinfo[0];
- const metadata = info.metadata && metadataToObject(info.metadata);
+ const meta = info.metadata && metadataToObject(info.metadata);
+ const ext = info.extmetadata;
return {
title: item.title,
url: info.url,
@@ -100,9 +93,13 @@
width: info.width,
height: info.height,
size: info.size,
- duration: metadata && (metadata.length ||
metadata.playtime_seconds) || undefined,
+ duration: meta && (meta.length || meta.playtime_seconds) ||
undefined,
derivatives: info.derivatives,
- ext: getExtMetadataValues(info.extmetadata)
+ artist: ext && ext.Artist && ext.Artist.value,
+ credit: ext && ext.Credit && ext.Credit.value,
+ license: ext && ext.LicenseShortName && ext.LicenseShortName.value,
+ license_url: ext && ext.LicenseUrl && ext.LicenseUrl.value,
+ description: ext && ext.ImageDescription &&
ext.ImageDescription.value
};
});
}
diff --git a/spec.yaml b/spec.yaml
index 262eef6..91bf376 100644
--- a/spec.yaml
+++ b/spec.yaml
@@ -597,7 +597,7 @@
width: /.+/
height: /.+/
size: /.+/
- ext: /.+/
+ license: /.+/
# from routes/definition.js
/{domain}/v1/page/definition/{title}:
@@ -1300,9 +1300,21 @@
description: a list of derivatives of the original file (applies only
to videos)
items:
type: object
- ext:
- type: object
- description: extended metadata about the object (provided by the
CommonsMetadata extension)
+ artist:
+ type: string
+ description: author of the media item
+ credit:
+ type: string
+ description: source of the media item
+ license:
+ type: string
+ description: license under which the media item is available on
Wikimedia Commons
+ license_url:
+ type: string
+ description: URL for the pertinent license
+ description:
+ type: string
+ description: description of the image from Wikimedia Commons
required:
- title
- type
@@ -1314,7 +1326,7 @@
- height
- size
- derivatives
- - ext
+ - license
additionalProperties: false
action:
--
To view, visit https://gerrit.wikimedia.org/r/392979
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic625f7c8a219be7d35a32d468b80781045570f4f
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: Mholloway <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits