server/page/studio_videos.js
// See ConfigureNewUpload.configure() for additional args and return value.
See ConfigureNewUpload.configure() for additional args and return value.
See ConfigureNewUpload . configure () for additional args and return value .
async uploadVideo(args) {
		const { title } = args
		assertType.string(title)
		const pathVideo = path.resolve(__dirname, "..", "test_videos", title + ".mp4")
		const pathImg = path.resolve(__dirname, "..", "test_videos", title + ".png")
		const createVideo = new Promise((resolve, reject) => {
			const python = spawn("python3", [path.resolve(__dirname, "..", "gen_video.py"), title])
			python.stdout.on("data", function (data) {
				console.log("PYTHON", data.toString())
			})
			python.on("close", async () => {
				this.log("Check if the video has been created")
				try {
					if (fs.existsSync(pathVideo)) {
						this.log("Video created!")
					} else {
						reject(
							"Error on creating the video, check that gen_video.py is working"
						)
					}
				} catch (err) {
					reject(
						"Error on creating the video, check that gen_video.py is working"
					)
				}
				this.log("Actually do the upload!")
				const inputTypeFile = await this.tab().waitForXPath(
					'//input[@type="file" and @name="Filedata"]'
				)
				await inputTypeFile.uploadFile(pathVideo)
				const configUpload = await ConfigureNewUpload.New(
					this.giveAwayTab()
				)
				var videoRes = await configUpload.configure(args)
				fs.unlinkSync(pathVideo)
				fs.unlinkSync(pathImg)
				resolve(videoRes)
			})
		})
		var res = null
		await createVideo
			.then((data) => {
				res = data
				return data
			})
			.catch((err) => {
				throw new Error(err)
			})
		return res
	}
async uploadVideo ( args ) { const { title } = args assertType . string ( title ) const pathVideo = path . resolve ( __dirname , ".." , "test_videos" , title + ".mp4" ) const pathImg = path . resolve ( __dirname , ".." , "test_videos" , title + ".png" ) const createVideo = new Promise ( ( resolve , reject ) => { const python = spawn ( "python3" , [ path . resolve ( __dirname , ".." , "gen_video.py" ) , title ] ) python . stdout . on ( "data" , function ( data ) { console . log ( "PYTHON" , data . toString ( ) ) } ) python . on ( "close" , async ( ) => { this . log ( "Check if the video has been created" ) try { if ( fs . existsSync ( pathVideo ) ) { this . log ( "Video created!" ) } else { reject ( "Error on creating the video, check that gen_video.py is working" ) } } catch ( err ) { reject ( "Error on creating the video, check that gen_video.py is working" ) } this . log ( "Actually do the upload!" ) const inputTypeFile = await this . tab ( ) . waitForXPath ( '//input[@type="file" and @name="Filedata"]' ) await inputTypeFile . uploadFile ( pathVideo ) const configUpload = await ConfigureNewUpload . New ( this . giveAwayTab ( ) ) var videoRes = await configUpload . configure ( args ) fs . unlinkSync ( pathVideo ) fs . unlinkSync ( pathImg ) resolve ( videoRes ) } ) } ) var res = null await createVideo . then ( ( data ) => { res = data return data } ) . catch ( ( err ) => { throw new Error ( err ) } ) return res }
See ConfigureNewUpload.configure() for additional args and return value.
See ConfigureNewUpload . configure () for additional args and return value .
// TODO: better selector for upload input.