MCPcopy Create free account
hub / github.com/Maintainerr/Maintainerr / createCollectionMedia

Function createCollectionMedia

apps/server/test/utils/data.ts:99–130  ·  view source on GitHub ↗
(
  collectionOrType?: Collection | MediaItemType,
  properties: Partial<CollectionMedia> = {},
)

Source from the content-addressed store, hash-verified

97};
98
99export const createCollectionMedia = (
100 collectionOrType?: Collection | MediaItemType,
101 properties: Partial<CollectionMedia> = {},
102): CollectionMedia => {
103 // Check if collectionOrType is a collection-like object (has an 'id' and 'type' property)
104 const isCollection =
105 collectionOrType !== null &&
106 typeof collectionOrType === 'object' &&
107 'id' in collectionOrType &&
108 'type' in collectionOrType;
109
110 const collectionToUse = isCollection
111 ? (collectionOrType as Collection)
112 : createCollection({ type: collectionOrType as MediaItemType });
113
114 return Object.assign(new CollectionMedia(), {
115 id: faker.number.int(),
116 collection: collectionToUse,
117 collectionId: collectionToUse.id,
118 addDate: faker.date.past(),
119 image_path: '',
120 isManual: false,
121 includedByRule: true,
122 manualMembershipSource:
123 null as CollectionMediaManualMembershipSource | null,
124 ruleEvaluationFailed: false,
125 mediaServerId: faker.number.int().toString(),
126 tmdbId: faker.number.int(),
127 sizeBytes: null,
128 ...properties,
129 });
130};
131
132type CollectionMediaWithMetadataOptional = Omit<
133 CollectionMediaWithMetadata,

Calls 2

createCollectionFunction · 0.85
toStringMethod · 0.80

Tested by 5

callSeriesTitleFunction · 0.72
callSeriesIdFunction · 0.72
callRankFunction · 0.72
callDailyRankFunction · 0.72
callSeasonRankFunction · 0.72