Skip to content

Commit 797ded0

Browse files
committed
Use human filetype names from hydrus
1 parent 9d16be6 commit 797ded0

File tree

3 files changed

+58
-25
lines changed

3 files changed

+58
-25
lines changed

src/hydrus-file.ts

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,22 @@ export interface HydrusTagService {
6060
display_tags: StatusesToTags;
6161
}
6262

63+
export enum UrlType {
64+
Post = 0,
65+
File = 2,
66+
Gallery = 3,
67+
Watchable = 4,
68+
Unknown = 5,
69+
}
70+
71+
export interface HydrusNotes {
72+
[name: string]: string;
73+
}
74+
75+
interface RatingsFromAPI {
76+
[service_key: string]: boolean | number | null;
77+
}
78+
6379
export interface HydrusFileFromAPI {
6480
file_id: number;
6581
hash: string;
@@ -68,37 +84,58 @@ export interface HydrusFileFromAPI {
6884
ext: string;
6985
width: number;
7086
height: number;
87+
duration?: number;
7188
has_audio: boolean;
89+
num_frames?: number;
90+
num_words?: number;
91+
92+
// TODO: make non-optional when v540 is minimum
93+
filetype_human?: string; // added in v540
94+
filetype_enum?: number; //added in v540
95+
blurhash?: string; // added in v545
96+
7297
known_urls: string[];
73-
detailed_known_urls?: DetailedKnownUrl[];
74-
duration?: number | null;
75-
num_frames?: number | null;
76-
num_words?: number | null;
7798
file_services: {
7899
current?: FileFileServices;
79100
deleted?: FileFileServices;
80101
};
81102
time_modified: number;
82-
83-
// removed in hydrus 514
84-
service_names_to_statuses_to_tags?: ServiceNamesToStatusesToTags;
85-
service_names_to_statuses_to_display_tags?: ServiceNamesToStatusesToTags;
86-
103+
service_names_to_statuses_to_tags?: ServiceNamesToStatusesToTags; // removed in v514
104+
service_names_to_statuses_to_display_tags?: ServiceNamesToStatusesToTags; // removed in v514
87105
service_keys_to_statuses_to_tags?: ServiceNamesToStatusesToTags;
88106
service_keys_to_statuses_to_display_tags?: ServiceNamesToStatusesToTags;
89-
90-
tags: {
91-
[serviceKey: string]: HydrusTagService;
92-
};
93-
94107
is_inbox: boolean;
95108
is_local: boolean;
96109
is_trashed: boolean;
97-
notes: {
98-
[name: string]: string;
110+
111+
notes?: HydrusNotes;
112+
113+
// added in v506
114+
// all known tags added in v507
115+
tags: {
116+
[serviceKey: string]: HydrusTagService
99117
};
118+
119+
detailed_known_urls?: DetailedKnownUrl[];
120+
121+
ipfs_multihashes?: Record<string, string>;
122+
123+
ratings?: RatingsFromAPI;
124+
125+
has_exif?: boolean; // added in v506
126+
has_human_readable_embedded_metadata?: boolean; // added in v506
127+
has_icc_profile?: boolean; // added in v506
128+
has_transparency?: boolean; // added in v552
129+
130+
thumbnail_width?: number; // added in v506
131+
thumbnail_height?: number; // added in v506
132+
133+
time_modified_details?: Record<string, number>; // added in v506
134+
135+
is_deleted?: boolean; // added in v506
100136
}
101137

138+
102139
export enum HydrusFileType {
103140
Image = 0,
104141
Video = 1,
@@ -117,14 +154,6 @@ export enum TagStatus {
117154
Petitioned = 3,
118155
}
119156

120-
export enum UrlType {
121-
Post = 0,
122-
File = 2,
123-
Gallery = 3,
124-
Watchable = 4,
125-
Unknown = 5,
126-
}
127-
128157
export function type(mime: string): HydrusFileType {
129158
if (
130159
[

src/templates/view-file-base.njk

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
<h1 class="card-title">{{title}}</h1>
1919

2020
<div>
21-
{% if mime %}
21+
{% if filetype_human %}
22+
<div {% if mime %} title="{{mime}}" {% endif %}>Type: {{filetype_human}}</div>
23+
{% elif mime %}
2224
<div>Type: {{mime}}</div>
2325
{% endif %}
2426
{% if width and height %}

src/view-file/view-file.controller.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export class ViewFileController {
9191
is_trashed,
9292
is_local,
9393
notes,
94+
filetype_human,
9495
} = file;
9596

9697
if (!file_id || (this.appConfig.errorNonLocal && !is_local)) {
@@ -156,6 +157,7 @@ export class ViewFileController {
156157
tag_services_to_tags,
157158
file_type,
158159
title,
160+
filetype_human,
159161
};
160162
}
161163

0 commit comments

Comments
 (0)