Skip to content

Commit 950e01c

Browse files
Updating pending commits, test if it's working
1 parent 5064599 commit 950e01c

3 files changed

Lines changed: 9 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ __pycache__/
1010
*.png
1111
*.jpeg
1212
*.svg
13+
*/*.svg
1314

1415
# C extensions
1516
*.so

basic-concepts/5b-builtin-function.py

100644100755
File mode changed.

real-world-examples/video_duration.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def get_duration(seconds):
1717

1818
# Display video(s) duration for given directory
1919
def display_video_duration(videos_list):
20+
global all_video_durations
2021
for video_file in videos_list:
2122
video_file_path = dir_path+"/"+video_file
2223

@@ -28,14 +29,15 @@ def display_video_duration(videos_list):
2829

2930
# Contains the duration of the video in terms of seconds
3031
video_duration = int(video.duration) # video length output is in seconds
32+
all_video_durations = all_video_durations + video_duration # adding all videos duration in seconds for total time.
3133
hours, minutes, seconds = get_duration(video_duration) #convert into human readable duration format
3234

3335
print(f"{video_file}: {hours}:{minutes}:{seconds}")
3436
except AttributeError:
3537
pass
3638

3739
if (len(sys.argv) != 2):
38-
exit("It needs video file list to work")
40+
exit("It needs video directory path to work")
3941

4042
dir_path = ""
4143
if(os.path.isdir(sys.argv[1])):
@@ -44,15 +46,15 @@ def display_video_duration(videos_list):
4446
# list to store vodeo files
4547
videos = []
4648

49+
# variable to store total duration
50+
all_video_durations = 0
51+
4752
# Iterate directory
4853
for path in os.listdir(dir_path):
4954
# check if current path is a file
5055
if os.path.isfile(os.path.join(dir_path, path)):
5156
videos.append(path)
5257

5358
display_video_duration(videos)
54-
55-
56-
# If you want to check the given file is a video file
57-
#if mimetypes.guess_type(path)[0].startswith('video'):
58-
# print('It is a video')
59+
hours, minutes, seconds = get_duration(all_video_durations)
60+
print(f"Total Video duration under directory {dir_path}: {hours}:{minutes}:{seconds}")

0 commit comments

Comments
 (0)