@@ -3,6 +3,7 @@ const log = msg => console.log(msg);
3
3
4
4
const API_KEY_OPTION = "OMDb API Key" ;
5
5
const API_URL = "https://www.omdbapi.com/" ;
6
+ const IMDB_BASE_URL = "https://www.imdb.com/title/" ;
6
7
7
8
module . exports = {
8
9
entry : start ,
@@ -50,6 +51,8 @@ async function start(params, settings) {
50
51
51
52
QuickAdd . variables = {
52
53
...selectedShow ,
54
+ imdbUrl : IMDB_BASE_URL + selectedShow . imdbID ,
55
+ Released : formatDateString ( selectedShow . Released ) ,
53
56
actorLinks : linkifyList ( selectedShow . Actors . split ( "," ) ) ,
54
57
genreLinks : linkifyList ( selectedShow . Genre . split ( "," ) ) ,
55
58
directorLink : linkifyList ( selectedShow . Director . split ( "," ) ) ,
@@ -67,6 +70,21 @@ function formatTitleForSuggestion(resultItem) {
67
70
return `(${ resultItem . Type === "movie" ? "M" : "TV" } ) ${ resultItem . Title } (${ resultItem . Year } )` ;
68
71
}
69
72
73
+ function formatDateString ( dateString ) {
74
+ const [ day , month , year ] = dateString . split ( ' ' ) ;
75
+ const monthNames = [ 'Jan' , 'Feb' , 'Mar' , 'Apr' , 'May' , 'Jun' , 'Jul' , 'Aug' , 'Sep' , 'Oct' , 'Nov' , 'Dec' ] ;
76
+ const monthIndex = monthNames . indexOf ( month ) ;
77
+
78
+ const date = new Date ( year , monthIndex , day ) ;
79
+
80
+ // Format the date as yyyy-mm-dd
81
+ const formattedYear = date . getFullYear ( ) ;
82
+ const formattedMonth = String ( date . getMonth ( ) + 1 ) . padStart ( 2 , '0' ) ;
83
+ const formattedDay = String ( date . getDate ( ) ) . padStart ( 2 , '0' ) ;
84
+
85
+ return `${ formattedYear } -${ formattedMonth } -${ formattedDay } ` ;
86
+ }
87
+
70
88
async function getByQuery ( query ) {
71
89
const searchResults = await apiGet ( API_URL , {
72
90
"s" : query ,
@@ -101,7 +119,7 @@ function linkifyList(list) {
101
119
}
102
120
103
121
function replaceIllegalFileNameCharactersInString ( string ) {
104
- return string . replace ( / [ \\ , # % & \{ \} \/ * < > $ \' \" : @ ] * / g, '' ) ;
122
+ return string . replace ( / [ \\ , # % & \{ \} \/ * < > $ \' \" : @ ] * / g, '' ) ;
105
123
}
106
124
107
125
async function apiGet ( url , data ) {
0 commit comments