Skip to content

Commit 3dc9345

Browse files
committed
created video.py
This file takes an absolute path to the folder where there are considerable number of videos and randomly plays them
1 parent 9ff04ee commit 3dc9345

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

video.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/python
2+
import os
3+
import subprocess
4+
import random
5+
6+
path=""
7+
video_list=[]
8+
9+
def set_path():
10+
if not os.path.exists("./path.txt"):
11+
path = raw_input("Enter the path where videos are stored")
12+
if path !="":
13+
try:
14+
f=open("./path.txt","w")
15+
except(IOError):
16+
print "Something is wrong with the file"
17+
exit
18+
f.write(path)
19+
f.close()
20+
21+
def play():
22+
try:
23+
f = open("./path.txt")
24+
except(IOError):
25+
print "Path invalid, please try again"
26+
exit
27+
path = f.readline()
28+
f.close()
29+
30+
video_list = os.listdir(path)
31+
os.chdir(path)
32+
33+
subprocess.Popen(["vlc", video_list[random.randint(0,len(video_list)-1)]])
34+
35+
if __name__=="__main__":
36+
set_path()
37+
play()

0 commit comments

Comments
 (0)