I made this script to run in the background to play tv-shows in the background like a TV channel. I tried putting all my files into a playlist and putting it on shuffle, however it meant that everything was played out of order. What I wanted was for a random show to come on, but for the episodes to play in order.
If that didn't make any sense then heres a screen shot of an example output:
![[Image: 2009-07-17_1253.png]](http://h.imagehost.org/0856/2009-07-17_1253.png)
![[Image: 2009-07-17_1254.png]](http://h.imagehost.org/0939/2009-07-17_1254.png)
![[Image: 2009-07-17_1255.png]](http://h.imagehost.org/0341/2009-07-17_1255.png)
![[Image: 2009-07-17_1257.png]](http://h.imagehost.org/0646/2009-07-17_1257.png)
(There was a lot of output from mplayer as well so I cut it out)
The script saves which episode was last played in each directory, so when the show is chosen again (randomly) it continues from that point.
Requirements
This is a python script, so you'll need to make sure you have it installed (2.6 if possible, I haven't tested it with 3.1).
Also, you'll need either mplayer or vlc installed. (To use VLC properly you need to have vlc set up to close when it finishes playing)
You will need to edit the config.txt file to contain the path to your files.
For the script to work you need to have a directory structure like this:
TvShows---->Show1---->Episodes
---->Show2---->Episodes
---->Show3---->Episodes
In this example you would put the path to "TvShows" directory into the config.txt
If you are on windows you will need to add the mplayer and/or vlc directory to your path variable, so that the script can call them from the command line (you won't need to worry about this on linux, I'm not sure about mac though).
* Copied from http://www.computerhope.com/issues/ch000549.htm *
To change the system environment variables, follow the below steps.
1. From the desktop, right-click My Computer and click properties.
2. In the System Properties window, click on the Advanced tab.
3. In the Advanced section, click the Environment Variables button.
4. Finally, in the Environment Variables window, highlight the path variable in the Systems Variable section and click edit. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below.
C:\Program Files;C:\Winnt;C:\Winnt\System32
So you'll want to add your mplayer or vlc directories to this.
Using
Now you can run MYOT.py to run the script. It will use VLC by default, if you want more options your going to have to put some options in at the command line. Luckily you can easily make a .bat or shell script to do this.
In windows
Make a new file in Notepad and save it as a .bat
Now in type this into the file:
Now you can just double click on the file to start it.
If you get an error here about python being missing, try adding pythons path to your path variable as well.
Options
"-fullscreen" Makes everything start in fullscreen (doesn't work with VLC yet, don't know how to get it to use fullscreen from the command line)
"-mplayer" Uses mplayer instead of VLC
"-first *name of directory you want to play first here*" Forces the script to play a certain directory first.
"-always *directory*" Forces the script to play the same directory all the time
"-dontInc" The episode number for directories don't increment
"-ps3" Uses mplayer-ps3 for use on the ps3 (mplayer-ps3 is a modified version of mplayer which plays movies much more smooth on the PS3(using linux) )
Other
The script will generate a file called MYOTcount.txt in each directory, it uses these to keep track of which episode to play. If you accidentally delete them, the script will make a new one next time it is run.
If you want to reset the count on all of your files you can run MYOTreset.py.
Download
MYOT_0.1.rar
Notes
Just a few things to watch out for. When you close mplayer or vlc, the script will start the next video, so if you want to stop the script close the console running it or use the task manager.
I know that the code is pretty messy, but it does work. If anyone wants to add to it, then do whatever you want. Any suggestions for future improvements would be welcome =D
Hopefully some people will find this useful, I use it all the time on a seperate PC that I have hooked up to my tv. Oh and about the name, I can't remember why I called it MYOT, it probably stood for something but I can't remember what it was...
*PS - Longest post I've ever written w00t =D*
If that didn't make any sense then heres a screen shot of an example output:
![[Image: 2009-07-17_1253.png]](http://h.imagehost.org/0856/2009-07-17_1253.png)
![[Image: 2009-07-17_1254.png]](http://h.imagehost.org/0939/2009-07-17_1254.png)
![[Image: 2009-07-17_1255.png]](http://h.imagehost.org/0341/2009-07-17_1255.png)
![[Image: 2009-07-17_1257.png]](http://h.imagehost.org/0646/2009-07-17_1257.png)
(There was a lot of output from mplayer as well so I cut it out)
The script saves which episode was last played in each directory, so when the show is chosen again (randomly) it continues from that point.
Requirements
This is a python script, so you'll need to make sure you have it installed (2.6 if possible, I haven't tested it with 3.1).
Also, you'll need either mplayer or vlc installed. (To use VLC properly you need to have vlc set up to close when it finishes playing)
You will need to edit the config.txt file to contain the path to your files.
For the script to work you need to have a directory structure like this:
TvShows---->Show1---->Episodes
---->Show2---->Episodes
---->Show3---->Episodes
In this example you would put the path to "TvShows" directory into the config.txt
If you are on windows you will need to add the mplayer and/or vlc directory to your path variable, so that the script can call them from the command line (you won't need to worry about this on linux, I'm not sure about mac though).
* Copied from http://www.computerhope.com/issues/ch000549.htm *
To change the system environment variables, follow the below steps.
1. From the desktop, right-click My Computer and click properties.
2. In the System Properties window, click on the Advanced tab.
3. In the Advanced section, click the Environment Variables button.
4. Finally, in the Environment Variables window, highlight the path variable in the Systems Variable section and click edit. Add or modify the path lines with the paths you wish the computer to access. Each different directory is separated with a semicolon as shown below.
C:\Program Files;C:\Winnt;C:\Winnt\System32
So you'll want to add your mplayer or vlc directories to this.
Using
Now you can run MYOT.py to run the script. It will use VLC by default, if you want more options your going to have to put some options in at the command line. Luckily you can easily make a .bat or shell script to do this.
In windows
Make a new file in Notepad and save it as a .bat
Now in type this into the file:
me Wrote:cd *PUT PATH TO DIRECTORY OF SCRIPT HERE*Where ** indicate things that depend on your setup.
python MYOT.py *OPTIONS HERE*
Now you can just double click on the file to start it.
If you get an error here about python being missing, try adding pythons path to your path variable as well.
Options
"-fullscreen" Makes everything start in fullscreen (doesn't work with VLC yet, don't know how to get it to use fullscreen from the command line)
"-mplayer" Uses mplayer instead of VLC
"-first *name of directory you want to play first here*" Forces the script to play a certain directory first.
"-always *directory*" Forces the script to play the same directory all the time
"-dontInc" The episode number for directories don't increment
"-ps3" Uses mplayer-ps3 for use on the ps3 (mplayer-ps3 is a modified version of mplayer which plays movies much more smooth on the PS3(using linux) )
Other
The script will generate a file called MYOTcount.txt in each directory, it uses these to keep track of which episode to play. If you accidentally delete them, the script will make a new one next time it is run.
If you want to reset the count on all of your files you can run MYOTreset.py.
Download
MYOT_0.1.rar
Notes
Just a few things to watch out for. When you close mplayer or vlc, the script will start the next video, so if you want to stop the script close the console running it or use the task manager.
I know that the code is pretty messy, but it does work. If anyone wants to add to it, then do whatever you want. Any suggestions for future improvements would be welcome =D
Hopefully some people will find this useful, I use it all the time on a seperate PC that I have hooked up to my tv. Oh and about the name, I can't remember why I called it MYOT, it probably stood for something but I can't remember what it was...
*PS - Longest post I've ever written w00t =D*
Edited: 2009-07-17, 7:52 am
