File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change
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 ()
You can’t perform that action at this time.
0 commit comments