()
| 33 | }; |
| 34 | |
| 35 | const updateDocs = async () => { |
| 36 | await terminalWait(); |
| 37 | console.log(`Updating video thumbnails, env is ${process.env.NODE_ENV}`); |
| 38 | |
| 39 | console.log("\nWaiting for database..."); |
| 40 | await waitForDatabase(); |
| 41 | console.log("Connected to database\n"); |
| 42 | |
| 43 | console.log("Getting Key..."); |
| 44 | await getKey(); |
| 45 | console.log("Key Got\n"); |
| 46 | |
| 47 | // console.log("env", process.env.KEY); |
| 48 | |
| 49 | console.log("Getting file list..."); |
| 50 | const files = await File.find({ |
| 51 | filename: { |
| 52 | $regex: |
| 53 | /\.(mp4|mov|avi|mkv|webm|wmv|flv|mpg|mpeg|3gp|3g2|mxf|ogv|ogg|m4v)$/i, |
| 54 | }, |
| 55 | "metadata.thumbnailID": "", |
| 56 | }); |
| 57 | |
| 58 | console.log("Found", files.length, "files"); |
| 59 | |
| 60 | for (let i = 0; i < files.length; i++) { |
| 61 | try { |
| 62 | const currentFile = files[i]; |
| 63 | |
| 64 | console.log(`Progress ${i + 1}/${files.length}`); |
| 65 | |
| 66 | const user = await User.findById(currentFile.metadata.owner); |
| 67 | |
| 68 | await createVideoThumbnail(currentFile, currentFile.filename, user); |
| 69 | } catch (e) { |
| 70 | console.log("error creating video thumbnail", e); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | console.log("Done"); |
| 75 | |
| 76 | process.exit(); |
| 77 | }; |
| 78 | |
| 79 | updateDocs(); |
no test coverage detected