9
9
<div class =" VideoSearch" >
10
10
<editor-input-field-pickable
11
11
v-model =" videoSearchWord"
12
- :title ="
13
- $t('components.editing_screen.labels.video_keyword', {
14
- source: 'NHK For School',
15
- })
16
- "
12
+ selector =" video"
13
+ :title =" $t('components.editing_screen.labels.video_keyword')"
17
14
:placeholder =" $t('components.editing_screen.placeholder.video_keyword')"
18
15
icon-name =" mdi-magnify"
19
16
:button-text =" $t('components.editing_screen.search_videos.search')"
20
17
@clickButton =" handleVideoSearchWord"
18
+ @changeMovie =" handleChangeMovie"
21
19
/>
22
20
23
21
<div v-if =" videoSearchResult.length > 0" class =" SearchResult" >
24
22
<h3 class =" SearchResultTitle" >
25
- {{
26
- $t('components.editing_screen.search_videos.search_result', {
27
- source: 'NHK For School',
28
- })
29
- }}
23
+ {{ $t('components.editing_screen.search_videos.search_result') }}
30
24
</h3 >
31
25
<ul class =" SearchResultList" >
32
26
<li v-for =" (v, i) in displayLists" :key =" i" class =" SearchResultItem" >
54
48
v-if =" v.videoUrl"
55
49
class =" SearchResultButton"
56
50
color =" #338dce"
57
- @click =" registerVideoUrl(v.videoUrl)"
51
+ @click ="
52
+ registerVideoUrl(
53
+ v.videoUrl,
54
+ v.videoTitle,
55
+ v.videoThumbnailUrl
56
+ )
57
+ "
58
58
>
59
59
<v-icon color =" white" > mdi-link </v-icon >
60
60
{{
81
81
<script lang="ts">
82
82
import { Vue , Component , Prop , Emit , Watch } from ' vue-property-decorator'
83
83
import EditorInputFieldPickable from ' ~/components/EditorInputFieldPickable.vue'
84
+ import { MovieListItem , Movie } from ' ~/types/movies'
84
85
85
- let movies: any [] = []
86
+ let movies: Movie [] = []
86
87
87
88
export type formData = {
88
89
videoUrl: string | null
89
90
videoTitle: string
91
+ videoSubTitle: string | null
92
+ videoDescription: string | null
93
+ videoPlayTime: string | null
90
94
videoThumbnailUrl: string | null
91
95
}
92
96
@@ -99,6 +103,9 @@ export default class EditLessonScreenInner3 extends Vue {
99
103
tempFormData = {
100
104
videoUrl: this .form .videoUrl ,
101
105
videoTitle: this .form .videoTitle ,
106
+ videoSubTitle: this .form .videoSubTitle ,
107
+ videoDescription: this .form .videoDescription ,
108
+ videoPlayTime: this .form .videoPlayTime ,
102
109
videoThumbnailUrl:
103
110
this .form .videoThumbnailUrl !== ' ' ? this .form .videoThumbnailUrl : null ,
104
111
}
@@ -109,24 +116,28 @@ export default class EditLessonScreenInner3 extends Vue {
109
116
default : () => ({
110
117
videoUrl: null ,
111
118
videoTitle: ' ' ,
119
+ videoSubTitle: ' ' ,
120
+ videoDescription: ' ' ,
121
+ videoPlayTime: ' ' ,
112
122
videoThumbnailUrl: ' ' ,
113
123
}),
114
124
})
115
125
public value! : formData
116
126
127
+ videoSourceType: string = ' '
117
128
videoSearchWord: string = ' '
118
- videoSearchResult: formData [] = []
129
+ videoSearchResult: ( formData | undefined ) [] = []
119
130
page: number = 1
120
131
pageSize: number = 5
121
132
length: number = 0
122
- displayLists: formData [] = []
133
+ displayLists: ( formData | undefined ) [] = []
123
134
124
135
mounted() {
125
- fetch (' /data/movies.json' )
126
- .then ((res ) => res .json ())
127
- .then ((data ) => {
128
- movies = data
129
- })
136
+ // fetch('/data/movies.json')
137
+ // .then((res) => res.json())
138
+ // .then((data) => {
139
+ // movies = data
140
+ // })
130
141
}
131
142
132
143
private get form(): formData {
@@ -147,6 +158,15 @@ export default class EditLessonScreenInner3 extends Vue {
147
158
this .tempFormData = this .value
148
159
}
149
160
161
+ private handleChangeMovie(selected : MovieListItem ) {
162
+ this .videoSourceType = selected .sourceType
163
+ fetch (` /data/${selected .dataFile } ` )
164
+ .then ((res ) => res .json ())
165
+ .then ((data ) => {
166
+ movies = data
167
+ })
168
+ }
169
+
150
170
private handleVideoSearchWord() {
151
171
if (this .videoSearchWord ) {
152
172
this .page = 1
@@ -158,33 +178,16 @@ export default class EditLessonScreenInner3 extends Vue {
158
178
return fullText .includes (this .videoSearchWord )
159
179
})
160
180
.map ((v ) => {
161
- const videoId = v [' 教材_ID' ]
162
- const videoType = parseInt (videoId .slice (5 , 6 ))
163
- const nfsMovieUrl = ' https://www2.nhk.or.jp/school/movie/'
164
- const videoDirectory = videoId .slice (0 , 8 )
165
- let videoThumbnailUrl = ` https://www.nhk.or.jp/das/image/${videoDirectory }/${videoId }_S_005.jpg `
166
- let videoUrl
167
- switch (videoType ) {
168
- case 1 :
169
- case 2 :
170
- videoUrl = ` ${nfsMovieUrl }bangumi.cgi?das_id=${videoId }&p=box `
181
+ let videoInfo
182
+ switch (this .videoSourceType ) {
183
+ case ' NHK' :
184
+ videoInfo = this .mapNhk (v )
171
185
break
172
- case 3 :
173
- case 4 :
174
- videoUrl = ` ${nfsMovieUrl }clip.cgi?das_id=${videoId }&p=box `
186
+ case ' junyiacademy' :
187
+ videoInfo = this .mapJunyiacademy (v )
175
188
break
176
- default :
177
- videoUrl = null
178
- videoThumbnailUrl = ' '
179
- }
180
- return {
181
- videoUrl ,
182
- videoTitle: v [' 教材_タイトル' ],
183
- videoSubTitle: v [' 教材_サブタイトル' ],
184
- videoDescription: v [' 教材_説明' ],
185
- videoPlayTime: v [' 教材_再生時間' ],
186
- videoThumbnailUrl ,
187
189
}
190
+ return videoInfo
188
191
})
189
192
190
193
this .length = Math .ceil (this .videoSearchResult .length / this .pageSize )
@@ -193,8 +196,10 @@ export default class EditLessonScreenInner3 extends Vue {
193
196
}
194
197
}
195
198
196
- private registerVideoUrl(url : string ) {
199
+ private registerVideoUrl(url : string , title : string , thumbnailUrl : string ) {
197
200
this .tempFormData .videoUrl = url
201
+ this .tempFormData .videoTitle = title
202
+ this .tempFormData .videoThumbnailUrl = thumbnailUrl
198
203
}
199
204
200
205
private pageChange(pageNumber : number ) {
@@ -204,6 +209,48 @@ export default class EditLessonScreenInner3 extends Vue {
204
209
)
205
210
}
206
211
212
+ private mapNhk(v : Movie ): formData {
213
+ const videoId = v .inherentProperties .教材_ID
214
+ const videoType = parseInt (videoId .slice (5 , 6 ))
215
+ const nfsMovieUrl = ' https://www2.nhk.or.jp/school/movie/'
216
+ const videoDirectory = videoId .slice (0 , 8 )
217
+ let videoThumbnailUrl = ` https://www.nhk.or.jp/das/image/${videoDirectory }/${videoId }_S_005.jpg `
218
+ let videoUrl
219
+ switch (videoType ) {
220
+ case 1 :
221
+ case 2 :
222
+ videoUrl = ` ${nfsMovieUrl }bangumi.cgi?das_id=${videoId }&p=box `
223
+ break
224
+ case 3 :
225
+ case 4 :
226
+ videoUrl = ` ${nfsMovieUrl }clip.cgi?das_id=${videoId }&p=box `
227
+ break
228
+ default :
229
+ videoUrl = null
230
+ videoThumbnailUrl = ' '
231
+ }
232
+ return {
233
+ videoUrl ,
234
+ videoTitle: v .title ,
235
+ videoSubTitle: v .inherentProperties .教材_ サブタイトル,
236
+ videoDescription: v .description ,
237
+ videoPlayTime: v .inherentProperties .教材_ 再生時間,
238
+ videoThumbnailUrl ,
239
+ }
240
+ }
241
+
242
+ private mapJunyiacademy(v : Movie ): formData {
243
+ const videoId: string = v .inherentProperties .url .slice (- 11 )
244
+ return {
245
+ videoUrl: v .inherentProperties .url ,
246
+ videoTitle: v .title ,
247
+ videoSubTitle: ' ' ,
248
+ videoDescription: v .description ,
249
+ videoPlayTime: ' ' ,
250
+ videoThumbnailUrl: ` https://img.youtube.com/vi/${videoId }/hqdefault.jpg ` ,
251
+ }
252
+ }
253
+
207
254
/* CORS 回避必須
208
255
@Watch('form.videoUrl')
209
256
onChangeVideoUrl() {
0 commit comments