Skip to content

Commit

Permalink
Merge pull request #873 from AI4Bharat/download_all
Browse files Browse the repository at this point in the history
changes for video duration
  • Loading branch information
kartikvirendrar authored Feb 3, 2025
2 parents 41e6ab4 + f071515 commit 51bb73b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
19 changes: 19 additions & 0 deletions src/common/CreateVideoDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const CreateVideoDialog = ({
speakerInfo,
speakerType,
setSpeakerType,
duration,
setDuration,
}) => {
const userOrgId = getLocalStorageData("userData").organization.id;

Expand All @@ -80,10 +82,16 @@ const CreateVideoDialog = ({

const videosInProject = useSelector((state)=>state.getProjectVideoList.data)
const [showPopup, setShowPopup] = useState(false);
const [showDurationSelector, setDurationSelector] = useState(false);
useEffect(() => {
if (videosInProject.some((video) => video.url === videoLink)) {
setShowPopup(true);
}
if (videoLink.length > 10 & !videoLink.includes("youtube")){
setDurationSelector(true);
}else{
setDurationSelector(false);
}
}, [videoLink, videosInProject]);

const handleClear = () => {
Expand Down Expand Up @@ -249,6 +257,17 @@ const CreateVideoDialog = ({
onChange={(event) => setVideoLink(event.target.value)}
sx={{ mt: 3 }}
/>

{showDurationSelector &&
<TextField
label={"Video Duration"}
fullWidth
defaultValue="00:00:00"
rows={1}
value={duration}
onChange={(event) => setDuration(event.target.value)}
sx={{ mt: 3 }}
/>}
{showPopup && (
<div
style={{
Expand Down
9 changes: 7 additions & 2 deletions src/containers/Organization/Project/Project.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { useEffect, useState } from "react";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate, useParams } from "react-router-dom";
import moment from "moment/moment";
import moment, { duration } from "moment/moment";
import { roles } from "utils";

//APIs
Expand Down Expand Up @@ -80,6 +80,7 @@ const Project = () => {
const [projectDetails, SetProjectDetails] = useState({});
const [videoList, setVideoList] = useState([]);
const [createVideoDialog, setCreateVideoDialog] = useState(false);
const [duration, setDuration] = useState("00:00:00");
const [videoLink, setVideoLink] = useState("");
const [isAudio, setIsAudio] = useState(false);
const [lang, setLang] = useState("");
Expand Down Expand Up @@ -245,6 +246,7 @@ const Project = () => {
const addNewVideoHandler = async () => {
const link = encodeURIComponent(videoLink.replace(/&amp;/g, "&"));
const desc = encodeURIComponent(videoDescription.replace(/&amp;/g, "&"));
const dur = encodeURIComponent(duration);
const create = true;

dispatch(
Expand All @@ -264,7 +266,8 @@ const Project = () => {
create,
voice,
speakerInfo,
speakerType
speakerType,
dur
);
dispatch(APITransport(apiObj));

Expand Down Expand Up @@ -527,6 +530,8 @@ const Project = () => {
speakerInfo={speakerInfo}
speakerType={speakerType}
setSpeakerType={setSpeakerType}
duration={duration}
setDuration={setDuration}
/>
)}

Expand Down
6 changes: 4 additions & 2 deletions src/redux/actions/api/Project/CreateNewVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class CreateNewVideoAPI extends API {
gender,
speakerInfo,
speakerType,
duration,
timeout = 2000
) {
super("GET", timeout, false);
Expand All @@ -25,12 +26,13 @@ export default class CreateNewVideoAPI extends API {
this.gender = gender;
this.speakerInfo = speakerInfo;
this.speakerType = speakerType;
this.duration = duration;
this.query =
this.speakerType === "multiple"
? `?multimedia_url=${url}&lang=${language}&is_audio_only=${isAudio}&project_id=${projectId}&description=${description}&create=${create}&gender=${gender}&speaker_info=${JSON.stringify(
speakerInfo
)}&multiple_speaker=true`
: `?multimedia_url=${url}&lang=${language}&is_audio_only=${isAudio}&project_id=${projectId}&description=${description}&create=${create}&gender=${gender}&multiple_speaker=false`;
)}&multiple_speaker=true&duration=${duration}`
: `?multimedia_url=${url}&lang=${language}&is_audio_only=${isAudio}&project_id=${projectId}&description=${description}&create=${create}&gender=${gender}&multiple_speaker=false&duration=${duration}`;
this.endpoint = `${super.apiEndPointAuto()}${ENDPOINTS.video}${this.query}`;
}

Expand Down

0 comments on commit 51bb73b

Please sign in to comment.