@christianriedl/media 1.0.148 → 1.0.150

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/iMedia.d.ts CHANGED
@@ -96,38 +96,38 @@ export declare enum EState {
96
96
  MarkedForDownload = 128
97
97
  }
98
98
  export interface IMediaItem {
99
- ItemType: EItemType;
100
- State: EState;
101
- Rating: number;
102
- GenreIdx: number;
103
- CreatorIdx: number;
104
- Name: string;
105
- Description: string;
106
- DLNAID: string;
107
- DLNAParentID: string;
108
- Year: number;
109
- Date: Date;
110
- Url: string;
111
- ThumbnailUrl: string;
99
+ itemType: EItemType;
100
+ state: EState;
101
+ rating: number;
102
+ genreIdx: number;
103
+ creatorIdx: number;
104
+ name: string;
105
+ description: string;
106
+ dlnaid: string;
107
+ dlnaParentId: string;
108
+ year: number;
109
+ date: Date;
110
+ url: string;
111
+ thumbnailUrl: string;
112
112
  title?: string;
113
113
  subTitle?: string;
114
114
  info?: string;
115
115
  }
116
116
  export interface IMediaListEntry {
117
- Name: string;
118
- Values: string[];
119
- Parents?: number[];
120
- Children?: number[][];
117
+ name: string;
118
+ values: string[];
119
+ parents?: number[];
120
+ children?: number[][];
121
121
  }
122
122
  export interface IMediaLists {
123
- ModificationTime: Date;
124
- PrivateCreatorIdx: number;
125
- Lists: IMediaListEntry[];
123
+ modificationTime: Date;
124
+ privateCreatorIdx: number;
125
+ lists: IMediaListEntry[];
126
126
  }
127
127
  export interface IMediaFolder extends IMediaItem {
128
- ChildCount: number;
129
- Folders: IMediaFolder[];
130
- Files: IMediaFile[];
128
+ childCount: number;
129
+ folders: IMediaFolder[];
130
+ files: IMediaFile[];
131
131
  prepared?: boolean;
132
132
  subfolderPrepared?: boolean;
133
133
  altColor?: boolean;
@@ -135,8 +135,8 @@ export interface IMediaFolder extends IMediaItem {
135
135
  populated?: boolean;
136
136
  }
137
137
  export interface IMediaFile extends IMediaItem {
138
- Extension: number;
139
- Size: number;
138
+ extension: number;
139
+ size: number;
140
140
  }
141
141
  export declare enum EOrientation {
142
142
  None = 0,
@@ -161,37 +161,37 @@ export declare enum EPictureFlags {
161
161
  Mask = 240
162
162
  }
163
163
  export interface IPictureFile extends IMediaFile {
164
- EventIdx: number;
165
- LocationIdx: number;
166
- PersonIdxs: number[];
167
- Height: number;
168
- Width: number;
169
- Orientation: EOrientation;
170
- Flags: EPictureFlags;
171
- ThumbHeight: number;
172
- ThumbWidth: number;
164
+ eventIdx: number;
165
+ locationIdx: number;
166
+ personIdxs: number[];
167
+ height: number;
168
+ width: number;
169
+ orientation: EOrientation;
170
+ flags: EPictureFlags;
171
+ thumbHeight: number;
172
+ thumbWidth: number;
173
173
  selected?: boolean;
174
174
  blob?: string;
175
175
  }
176
176
  export interface IAudioFile extends IMediaFile {
177
- BitRate: number;
178
- Duration: number;
179
- Extension: number;
180
- SampleRate: number;
181
- Size: number;
182
- TrackNo: number;
177
+ bitRate: number;
178
+ duration: number;
179
+ extension: number;
180
+ sampleRate: number;
181
+ size: number;
182
+ trackNo: number;
183
183
  }
184
184
  export interface IVideoFile extends IMediaFile {
185
- ActorIdxs: number[];
186
- BitRate: number;
187
- FrameRate: number;
188
- CountryIdx: number;
189
- Duration: number;
190
- Extension: number;
191
- Size: number;
192
- Height: number;
193
- Width: number;
194
- AudioStreams: string;
185
+ actorIdxs: number[];
186
+ bitRate: number;
187
+ frameRate: number;
188
+ countryIdx: number;
189
+ duration: number;
190
+ extension: number;
191
+ size: number;
192
+ height: number;
193
+ width: number;
194
+ audioStreams: string;
195
195
  }
196
196
  export interface IAudioInfo {
197
197
  codec: string;
@@ -8,15 +8,15 @@ export class LocationHelper {
8
8
  }
9
9
  static addLocationParents(mediaService, list, rating, ratingMap) {
10
10
  const parentFolder = mediaService.getFolder(`ph.${rating}.lo`);
11
- parentFolder.Folders.length = 0;
12
- for (let i = 0; i < list.Parents.length; i++) {
13
- if (list.Parents[i] < 0)
14
- LocationHelper.addLocationParent(mediaService, parentFolder, i, list.Values[i], list.Children[i], rating, ratingMap);
11
+ parentFolder.folders.length = 0;
12
+ for (let i = 0; i < list.parents.length; i++) {
13
+ if (list.parents[i] < 0)
14
+ LocationHelper.addLocationParent(mediaService, parentFolder, i, list.values[i], list.children[i], rating, ratingMap);
15
15
  }
16
- parentFolder.Folders.sort((x1, x2) => x1.Name.localeCompare(x2.Name));
17
- for (let i = 0; i < parentFolder.Folders.length; i++) {
16
+ parentFolder.folders.sort((x1, x2) => x1.name.localeCompare(x2.name));
17
+ for (let i = 0; i < parentFolder.folders.length; i++) {
18
18
  if ((i % 2) != 0)
19
- parentFolder.Folders[i].altColor = true;
19
+ parentFolder.folders[i].altColor = true;
20
20
  }
21
21
  }
22
22
  static addLocationParent(mediaService, parentFolder, index, name, children, rating, ratingMap) {
@@ -26,58 +26,58 @@ export class LocationHelper {
26
26
  if (!folder) {
27
27
  folder =
28
28
  {
29
- CreatorIdx: -1,
30
- GenreIdx: -1,
31
- ChildCount: 0,
32
- Description: "",
33
- Files: null,
34
- Url: null,
35
- ThumbnailUrl: null,
36
- Year: 1970,
37
- Date: new Date(1970, 0, 1),
38
- ItemType: EItemType.PictureCategory,
39
- DLNAParentID: `ph.${rating}.lo`,
40
- DLNAID: folderId,
41
- Name: name,
42
- Rating: ratingMap,
43
- Folders: [],
44
- State: EState.FolderVirtual
29
+ creatorIdx: -1,
30
+ genreIdx: -1,
31
+ childCount: 0,
32
+ description: "",
33
+ files: null,
34
+ url: null,
35
+ thumbnailUrl: null,
36
+ year: 1970,
37
+ date: new Date(1970, 0, 1),
38
+ itemType: EItemType.PictureCategory,
39
+ dlnaParentId: `ph.${rating}.lo`,
40
+ dlnaid: folderId,
41
+ name: name,
42
+ rating: ratingMap,
43
+ folders: [],
44
+ state: EState.FolderVirtual
45
45
  };
46
- allFolders[folder.DLNAID] = folder;
46
+ allFolders[folder.dlnaid] = folder;
47
47
  }
48
- folder.info = folder.Name;
49
- folder.CreatorIdx = index; // !! used to store Location Index
48
+ folder.info = folder.name;
49
+ folder.creatorIdx = index; // !! used to store Location Index
50
50
  if (children && children.length > 0)
51
51
  folder.mustExpand = true;
52
- parentFolder.Folders.push(folder);
52
+ parentFolder.folders.push(folder);
53
53
  }
54
54
  static expandLocationFolder(mediaService, parentFolder, expandFolder) {
55
55
  const altColor = expandFolder.altColor;
56
56
  const pictureLocations = mediaService.pictureLocation;
57
- const locationIdx = expandFolder.CreatorIdx; // Used to store locationIdx !!
57
+ const locationIdx = expandFolder.creatorIdx; // Used to store locationIdx !!
58
58
  if (locationIdx >= 0) {
59
- const children = pictureLocations.Children[locationIdx];
59
+ const children = pictureLocations.children[locationIdx];
60
60
  if (!children || !children.length)
61
61
  return;
62
62
  const expandedList = [];
63
63
  const hasChildrenList = [];
64
64
  for (let i = 0; i < children.length; i++) {
65
65
  const childIdx = children[i];
66
- var folder = mediaService.getFolder(`${expandFolder.DLNAParentID}.${childIdx}|`);
66
+ var folder = mediaService.getFolder(`${expandFolder.dlnaParentId}.${childIdx}|`);
67
67
  if (folder) {
68
- if (pictureLocations.Children[childIdx] && pictureLocations.Children[childIdx].length)
68
+ if (pictureLocations.children[childIdx] && pictureLocations.children[childIdx].length)
69
69
  hasChildrenList.push(folder);
70
- folder.CreatorIdx = childIdx; // used to store location index !!
70
+ folder.creatorIdx = childIdx; // used to store location index !!
71
71
  expandedList.push(folder);
72
- expandFolder.Folders.push(folder);
72
+ expandFolder.folders.push(folder);
73
73
  folder.altColor = altColor;
74
74
  }
75
75
  }
76
76
  expandFolder.mustExpand = false;
77
- expandFolder.ChildCount = expandFolder.Folders.length;
78
- expandFolder.info = `${expandFolder.Name} (${expandFolder.ChildCount})`;
79
- const idx = parentFolder.Folders.indexOf(expandFolder);
80
- parentFolder.Folders.splice(idx + 1, 0, ...expandedList);
77
+ expandFolder.childCount = expandFolder.folders.length;
78
+ expandFolder.info = `${expandFolder.name} (${expandFolder.childCount})`;
79
+ const idx = parentFolder.folders.indexOf(expandFolder);
80
+ parentFolder.folders.splice(idx + 1, 0, ...expandedList);
81
81
  for (let i = 0; i < hasChildrenList.length; i++) {
82
82
  LocationHelper.expandLocationFolder(mediaService, parentFolder, hasChildrenList[i]);
83
83
  }
@@ -88,12 +88,12 @@ export class LocationHelper {
88
88
  const childAlbums = {};
89
89
  var childYears = new Set();
90
90
  // Take direct subfolders
91
- if (folder.Folders) {
91
+ if (folder.folders) {
92
92
  LocationHelper.collectAlbums(childAlbums, childYears, folder);
93
- folder.Folders.length = 0;
93
+ folder.folders.length = 0;
94
94
  }
95
95
  else
96
- folder.Folders = [];
96
+ folder.folders = [];
97
97
  if (Object.keys(childAlbums).length < maxAlbums) {
98
98
  // Create Direct Album Children
99
99
  const albumNames = Object.keys(childAlbums);
@@ -101,40 +101,40 @@ export class LocationHelper {
101
101
  for (let i = 0; i < albumNames.length; i++) {
102
102
  const albumName = albumNames[i];
103
103
  const album = {
104
- CreatorIdx: -1,
105
- GenreIdx: -1,
106
- ChildCount: 0,
107
- Description: "",
108
- Folders: null,
109
- Url: "",
110
- ThumbnailUrl: null,
111
- Year: 1970,
112
- Date: new Date(1970, 0, 1),
113
- ItemType: EItemType.PictureAlbum,
114
- DLNAParentID: folder.DLNAID,
115
- DLNAID: `${folder.DLNAID}v${i}`,
116
- Name: albumName,
117
- Rating: 0,
118
- Files: [],
119
- State: EState.FolderVirtual
104
+ creatorIdx: -1,
105
+ genreIdx: -1,
106
+ childCount: 0,
107
+ description: "",
108
+ folders: null,
109
+ url: "",
110
+ thumbnailUrl: null,
111
+ year: 1970,
112
+ date: new Date(1970, 0, 1),
113
+ itemType: EItemType.PictureAlbum,
114
+ dlnaParentId: folder.dlnaid,
115
+ dlnaid: `${folder.dlnaid}v${i}`,
116
+ name: albumName,
117
+ rating: 0,
118
+ files: [],
119
+ state: EState.FolderVirtual
120
120
  };
121
121
  var folders = childAlbums[albumName];
122
122
  for (let j = 0; j < folders.length; j++) {
123
123
  const subFolder = folders[j];
124
- album.Rating |= subFolder.Rating;
125
- album.Files.splice(0, 0, ...subFolder.Files);
124
+ album.rating |= subFolder.rating;
125
+ album.files.splice(0, 0, ...subFolder.files);
126
126
  }
127
- album.Files.sort((x1, x2) => {
128
- if (x1.Date < x2.Date)
127
+ album.files.sort((x1, x2) => {
128
+ if (x1.date < x2.date)
129
129
  return -1;
130
- if (x1.Date > x2.Date)
130
+ if (x1.date > x2.date)
131
131
  return 1;
132
132
  return 0;
133
133
  });
134
- album.ChildCount = album.Files.length;
135
- album.info = `${album.Name} (${album.ChildCount})`;
136
- allFolders[album.DLNAID] = album;
137
- folder.Folders.push(album);
134
+ album.childCount = album.files.length;
135
+ album.info = `${album.name} (${album.childCount})`;
136
+ allFolders[album.dlnaid] = album;
137
+ folder.folders.push(album);
138
138
  }
139
139
  }
140
140
  else {
@@ -145,18 +145,18 @@ export class LocationHelper {
145
145
  const childAlbumGroup = childAlbums[key];
146
146
  for (let i = 0; i < childAlbumGroup.length; i++) {
147
147
  const childAlbum = childAlbumGroup[i];
148
- let yearAlbums = yearDict[childAlbum.Year];
148
+ let yearAlbums = yearDict[childAlbum.year];
149
149
  if (yearAlbums) {
150
- albums = yearAlbums[childAlbum.Name];
150
+ albums = yearAlbums[childAlbum.name];
151
151
  if (albums)
152
152
  albums.push(childAlbum);
153
153
  else
154
- yearAlbums[childAlbum.Name] = [childAlbum];
154
+ yearAlbums[childAlbum.name] = [childAlbum];
155
155
  }
156
156
  else {
157
157
  yearAlbums = {};
158
- yearAlbums[childAlbum.Name] = [childAlbum];
159
- yearDict[childAlbum.Year] = yearAlbums;
158
+ yearAlbums[childAlbum.name] = [childAlbum];
159
+ yearDict[childAlbum.year] = yearAlbums;
160
160
  }
161
161
  }
162
162
  }
@@ -164,89 +164,89 @@ export class LocationHelper {
164
164
  years.sort();
165
165
  for (let i = 0; i < years.length; i++) {
166
166
  var yearCategory = {
167
- CreatorIdx: -1,
168
- GenreIdx: -1,
169
- ChildCount: 0,
170
- Description: "",
171
- Url: null,
172
- ThumbnailUrl: null,
173
- Year: 1970,
174
- Date: new Date(1970, 0, 1),
175
- Files: null,
176
- ItemType: EItemType.PictureCategory,
177
- DLNAParentID: folder.DLNAID,
178
- DLNAID: `${folder.DLNAID}y${i}`,
179
- Name: years[i].toString(),
180
- Rating: 0,
181
- Folders: [],
182
- State: EState.FolderVirtual
167
+ creatorIdx: -1,
168
+ genreIdx: -1,
169
+ childCount: 0,
170
+ description: "",
171
+ url: null,
172
+ thumbnailUrl: null,
173
+ year: 1970,
174
+ date: new Date(1970, 0, 1),
175
+ files: null,
176
+ itemType: EItemType.PictureCategory,
177
+ dlnaParentId: folder.dlnaid,
178
+ dlnaid: `${folder.dlnaid}y${i}`,
179
+ name: years[i].toString(),
180
+ rating: 0,
181
+ folders: [],
182
+ state: EState.FolderVirtual
183
183
  };
184
- allFolders[yearCategory.DLNAID] = yearCategory;
185
- folder.Folders.push(yearCategory);
184
+ allFolders[yearCategory.dlnaid] = yearCategory;
185
+ folder.folders.push(yearCategory);
186
186
  const yearAlbums = yearDict[years[i]];
187
187
  let j = 0;
188
188
  for (const yearAlbumKey in yearAlbums) {
189
189
  var album = {
190
- CreatorIdx: -1,
191
- GenreIdx: -1,
192
- ChildCount: 0,
193
- Description: "",
194
- Folders: null,
195
- Url: "",
196
- ThumbnailUrl: null,
197
- Year: 1970,
198
- Date: new Date(1970, 0, 1),
199
- ItemType: EItemType.PictureAlbum,
200
- DLNAParentID: yearCategory.DLNAID,
201
- DLNAID: `${yearCategory.DLNAID}v${j}`,
202
- Name: yearAlbumKey,
203
- Rating: 0,
204
- Files: [],
205
- State: EState.FolderVirtual
190
+ creatorIdx: -1,
191
+ genreIdx: -1,
192
+ childCount: 0,
193
+ description: "",
194
+ folders: null,
195
+ url: "",
196
+ thumbnailUrl: null,
197
+ year: 1970,
198
+ date: new Date(1970, 0, 1),
199
+ itemType: EItemType.PictureAlbum,
200
+ dlnaParentId: yearCategory.dlnaid,
201
+ dlnaid: `${yearCategory.dlnaid}v${j}`,
202
+ name: yearAlbumKey,
203
+ rating: 0,
204
+ files: [],
205
+ state: EState.FolderVirtual
206
206
  };
207
207
  const subFolders = yearAlbums[yearAlbumKey];
208
208
  for (let k = 0; k < subFolders.length; k++) {
209
209
  const subFolder = subFolders[k];
210
- album.Rating |= subFolder.Rating;
211
- album.Files.splice(0, 0, ...subFolder.Files);
210
+ album.rating |= subFolder.rating;
211
+ album.files.splice(0, 0, ...subFolder.files);
212
212
  }
213
- album.Files.sort((x1, x2) => {
214
- if (x1.Date < x2.Date)
213
+ album.files.sort((x1, x2) => {
214
+ if (x1.date < x2.date)
215
215
  return -1;
216
- if (x1.Date > x2.Date)
216
+ if (x1.date > x2.date)
217
217
  return 1;
218
218
  return 0;
219
219
  });
220
- album.ChildCount = album.Files.length;
221
- album.info = `${album.Name} (${album.ChildCount})`;
222
- yearCategory.Rating |= album.Rating;
223
- allFolders[album.DLNAID] = album;
224
- yearCategory.Folders.push(album);
220
+ album.childCount = album.files.length;
221
+ album.info = `${album.name} (${album.childCount})`;
222
+ yearCategory.rating |= album.rating;
223
+ allFolders[album.dlnaid] = album;
224
+ yearCategory.folders.push(album);
225
225
  j++;
226
226
  }
227
- yearCategory.ChildCount = yearCategory.Folders.length;
228
- yearCategory.info = `${yearCategory.Name} (${yearCategory.ChildCount})`;
227
+ yearCategory.childCount = yearCategory.folders.length;
228
+ yearCategory.info = `${yearCategory.name} (${yearCategory.childCount})`;
229
229
  }
230
230
  }
231
- folder.ChildCount = folder.Folders.length;
232
- folder.info = `${folder.Name} (${folder.ChildCount})`;
231
+ folder.childCount = folder.folders.length;
232
+ folder.info = `${folder.name} (${folder.childCount})`;
233
233
  folder.mustExpand = false;
234
234
  folder.populated = true;
235
235
  return true;
236
236
  }
237
237
  static collectAlbums(albums, years, folder) {
238
- for (let i = 0; i < folder.Folders.length; i++) {
239
- const album = folder.Folders[i];
240
- if (album.ItemType == EItemType.PictureAlbum) {
238
+ for (let i = 0; i < folder.folders.length; i++) {
239
+ const album = folder.folders[i];
240
+ if (album.itemType == EItemType.PictureAlbum) {
241
241
  LocationHelper.collectAlbum(albums, years, album);
242
242
  }
243
- else if (album.Folders != null) {
244
- for (let j = 0; j < album.Folders.length; j++) {
245
- const subalbum = album.Folders[j];
246
- if (subalbum.ItemType == EItemType.PictureAlbum) {
243
+ else if (album.folders != null) {
244
+ for (let j = 0; j < album.folders.length; j++) {
245
+ const subalbum = album.folders[j];
246
+ if (subalbum.itemType == EItemType.PictureAlbum) {
247
247
  LocationHelper.collectAlbum(albums, years, subalbum);
248
248
  }
249
- else if (subalbum.ItemType == EItemType.PictureCategory) {
249
+ else if (subalbum.itemType == EItemType.PictureCategory) {
250
250
  LocationHelper.collectAlbums(albums, years, subalbum);
251
251
  }
252
252
  }
@@ -254,18 +254,18 @@ export class LocationHelper {
254
254
  }
255
255
  }
256
256
  static collectAlbum(albums, years, album) {
257
- const folders = albums[album.Name];
257
+ const folders = albums[album.name];
258
258
  if (folders)
259
259
  folders.push(album);
260
260
  else
261
- albums[album.Name] = [album];
262
- years.add(album.Year);
263
- if (album.Files) {
261
+ albums[album.name] = [album];
262
+ years.add(album.year);
263
+ if (album.files) {
264
264
  // This required because different albums are collected
265
- for (let i = 0; i < album.Files.length; i++) {
266
- album.Files[i].Url = album.Url + album.Files[i].Url;
265
+ for (let i = 0; i < album.files.length; i++) {
266
+ album.files[i].url = album.url + album.files[i].url;
267
267
  }
268
- album.Url = "";
268
+ album.url = "";
269
269
  }
270
270
  }
271
271
  }
@@ -61,14 +61,14 @@ export class MediaHelper {
61
61
  }
62
62
  static getPhotoDisplayName(folder, pictureFile, pictureLocations, album) {
63
63
  let emptyName = "|";
64
- const url = folder.Url + pictureFile.Url;
65
- const name = pictureFile.Name;
64
+ const url = folder.url + pictureFile.url;
65
+ const name = pictureFile.name;
66
66
  if (!url.includes(name)) {
67
67
  return name;
68
68
  }
69
- if (pictureFile.LocationIdx >= 0 && pictureLocations) {
70
- let location = pictureLocations.Values[pictureFile.LocationIdx];
71
- if (!album || !album.Name.includes(location)) {
69
+ if (pictureFile.locationIdx >= 0 && pictureLocations) {
70
+ let location = pictureLocations.values[pictureFile.locationIdx];
71
+ if (!album || !album.name.includes(location)) {
72
72
  return location;
73
73
  }
74
74
  }