Skip to content

Commit

Permalink
server: add tag "category" fallback for tar files
Browse files Browse the repository at this point in the history
Tags names were described in tar files with
data.tagname and was named "TagN" if data.tagname
wasn't defined, with "N" an incremental number.
It is now possible to have tags with property
data.category as a fallback to data.tagname. In
order of priority:

1. data.tagname
2. data.category
3. "TagN"

If tar file contains both tags with data.tagname
or data.category, and tags without it, tags
without a name will be named incrementally without
counting tags with a name.
  • Loading branch information
maxime-beguin committed Jan 21, 2021
1 parent d9f55df commit 30e3876
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 11.1.0 / YYYY-MM-DD

## NEW FEATURES

- Add support for "category" property of tag indexes in tar archives. Actually the property data.tagname was used as the tag name with a fallback to "Tag N". An intermediate fallback has been added with the property "category" as the first fallback if data.tagname is not set.

# 11.0.3 / 2020-11-30

## BUG FIXES
Expand Down
5 changes: 3 additions & 2 deletions app/server/packages/TarPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ TarPackage.prototype.saveTimecodes = function() {

// Format points of interest
function(pointsOfInterest, spriteReferences, callback) {
var countTagsWithoutName = 0;
var tags = [];
var timecodes = [];

Expand Down Expand Up @@ -602,8 +603,8 @@ TarPackage.prototype.saveTimecodes = function() {
case 'tag':
tags.push({
value: pointOfInterest.timecode,
name: pointOfInterest.data && pointOfInterest.data.tagname ?
pointOfInterest.data.tagname : 'Tag' + (tags.length + 1)
name: (pointOfInterest.data && (pointOfInterest.data.tagname || pointOfInterest.data.category)) ||
'Tag' + (++countTagsWithoutName)
});
break;
default:
Expand Down
3 changes: 2 additions & 1 deletion docs/watcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ It can contain some optional properties:
"timecode": 9500, // timecode in ms
"type": "tag", // timecode type (must be "image" or "tag")
"data": { // Optional - related information for tag timecode
"tagname": "Very important moment" // tagname to display, if not defined, will be replaced by 'Tag N' where N is the number of the tag
"category": "Tag category", // Optional - The name of the category the tag belongs to used as a fallback when no tag name is specified
"tagname": "Very important moment" // Optional - Tag name, if not defined the category will be used as the tag name and if neither category nor tag name are defined it will be replaced by 'TagN' where N is an incremental number
}
},
...
Expand Down

0 comments on commit 30e3876

Please sign in to comment.