I did post the src, i'll re-post just in case.

basically what I do is yes, I see if what we get from freevo contains a
rar in one of the options, if so, extract it to /tmp/wm_XXXXX/file and
then have mplayer play all the files in /tmp/wm_XXXXX/* which works
stand alone.

anyway here's my src don't say it's nasty : )
I warned you.

Justin Wetherell wrote:

> Can you post the source, if it hasn't already been posted? If you
> extract a rar to /tmp/unpacked and then call "mplayer /tmp/unpacked"
> then I could see it looping.
>
> On 11/23/05, *oliver* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
>
>     Because tv-shows get released as rar's and quite often pumped directly
>     onto bit torrent networks. Usenet btw is one i didn't even think of.
>     Splitting files for usenet is easyer aswell. And what about
>     photo's. If
>     I have a few albums packed in rar's on a CD maybe even, I'd have to
>     extract them manually all before viewing.
>
>     I looked at unpack.py but it uses kaa.notifier. From what I can gather
>     that is a module for freevo 2.0. I'm still stranded with 1.5.4
>     currently. Also from what I could understand from the src is that it
>     just extracts it to a dir, doesn't play it right away.
>
>     Anyway, why would my wrapper keep on looping when launched from
>     freevo?
>     Or more precicly, why would freevo keep on launching mplayer after
>     it is
>     finished?
>
>     Jason Tackaberry wrote:
>
>     >On Wed, 2005-11-23 at 18:49 +0100, oliver wrote:
>     >
>     >
>     >>First of all, because rar's are 'saver' to transport over Internet
>     >>streams then plain avi's. You have smaller parts and they are with
>     >>recovery options.
>     >>
>     >>
>     >
>     >Seems to me that splitting the file and using par2 for error recovery
>     >would be better.  But I suppose if you want to distribute
>     multiple files
>     >one might use rar.  I'd prefer a tarball, but maybe tar is less
>     >available on Windows.
>     >
>     >
>     >
>     >>Secondly, If I download a rar via bit torrent for example, I
>     might want
>     >>to keep seeding those rar files. Thus I want to keep the rar
>     files much
>     >>longer then that 2 hrs I'm watching it.
>     >>
>     >>
>     >
>     >Fair enough.  Although, why split the movie up into rar parts if
>     >bittorrent is the transport medium?  I can see it on Usenet, but why
>     >bittorrent?
>     >
>     >Jason.
>     >
>     >
>
>
>     -------------------------------------------------------
>     This SF.net email is sponsored by: Splunk Inc. Do you grep through
>     log files
>     for problems?  Stop!  Download the new AJAX search engine that makes
>     searching your log files as easy as surfing the  web.  DOWNLOAD
>     SPLUNK!
>     http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
>     <http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click>
>     _______________________________________________
>     Freevo-devel mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/freevo-devel
>
>
/*
 * wrapper_mplayer.c v0.01 Oliver ([EMAIL PROTECTED])
 * 
 * Mplayer rar filetype wraper thingy.
 * This thing should be a temporary thing until I get compFUSEd to work with
 * files like rar. It's work in progress so until then, this little dirty
 * thing.
 *
 * Warning , use this at your own risc, I'm not responsible for anything!
 * Note: Right now it extracts all files from the rar archive and plays
 * all avi files in that dir with mplayer. You could change the
 * COMMAND_MPLAYER and use this wrapper with xine too I suppose, since
 * all paramayers are plainly copyed over. The only thing that might get
 * tricky is that the file(s) to be played will be appended to that commandline
 * other then that it should be fine.
 * 
 * It's GPLed so you can change it as much as you want.
 */

#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/types.h>
#include <dirent.h>

#define COMMAND_MPLAYER "/usr/bin/mplayer"
#define COMMAND_UNRAR "/usr/bin/unrar"

#define EXTENTION_RAR ".rar"
#define OPTIONS_RAR "e"

int main(int argc, char *argv[]) {
        int retval;
        int i;

        retval = 0;

        /* Search through all the supplied arguments for any reference to 
rarfiles
         * we start at the back, as it's the most likly place to have the file 
in question.
         */
        for (i = argc -1; i > 0; i--) {
                char *extention_location;
                extention_location = strstr(argv[i], EXTENTION_RAR);
                if (extention_location) {
                        char dirtemplate[15] = "/tmp/wm_XXXXXX\0", 
tempdirname[15];
                        char *tempdirname_ptr;
                        char *external_command;
                        int j, external_command_length;
                        
                        DIR *tempdir;
                        struct dirent **tempdirnamelist;
                        int namelist;
                        char *tempfilename;
                        
                        tempdirname_ptr = tempdirname;

                        /* So we found a rar file. Step 1, extract all files to 
a temporary dir */
                        tempdirname_ptr = mkdtemp(dirtemplate);
                        external_command = malloc(
                                                strlen(COMMAND_UNRAR) 
+strlen(OPTIONS_RAR) 
                                                +strlen(tempdirname_ptr) 
+strlen(argv[i]
                                        ) +4/*spaces and \0*/);
                        sprintf(external_command, "%s %s %s %s", COMMAND_UNRAR, 
OPTIONS_RAR, argv[i], tempdirname_ptr);
                        if (system(external_command)) {
                                perror("system");
                                retval = 1;
                        }
                        free(external_command);

                        /* rar file extracted, step 2 assemble new commandline 
*/
                        external_command_length = strlen(COMMAND_MPLAYER) 
+strlen(tempdirname_ptr) +8;
                        external_command = malloc(external_command_length);
                        strcpy(external_command, COMMAND_MPLAYER);
                        for (j = 1; j < argc; j++) {
                                if (j != i) {
                                        external_command_length += 1 
+strlen(argv[j]);
                                        external_command = 
realloc(external_command, external_command_length);
                                        strcat(external_command, " ");
                                        strcat(external_command, argv[j]);
                                }
                        }
                        strcat(external_command, " ");
                        strcat(external_command, tempdirname_ptr);
                        strcat(external_command, "/*.avi");
                        if (system(external_command)) {
                                perror("system");
                                retval = 1;
                        }

                        /* cleanup! */
                        /* remove all files in temporary dir */
                        tempdir = opendir(tempdirname_ptr);
                        if (!tempdir) {
                                perror("opendir");
                                retval = 1;
                        }
                        namelist = scandir(tempdirname_ptr, &tempdirnamelist, 
NULL, alphasort);
                        if (namelist < 0) {
                                perror("scandir");
                        } else {
                                tempfilename = malloc(strlen(tempdirname_ptr));
                                while((namelist--) -2) { /* last 2 entries are 
. .., skip those */
                                        tempfilename = realloc(
                                                                tempfilename, 
strlen(tempdirname_ptr)
                                                                
+strlen(tempdirnamelist[namelist]->d_name)
                                                                +2      
                                                        );
                                        sprintf(tempfilename, "%s/%s", 
tempdirname_ptr, tempdirnamelist[namelist]->d_name);
                                        if (remove(tempfilename)) {
                                                perror("remove");
                                                retval = 1;
                                        }
                                        free(tempdirnamelist[namelist]);
                                }
                                free(tempdirnamelist);
                        }
                        closedir(tempdir);
                        
                        /* remove temporary dir too */
                        if (rmdir(tempdirname_ptr)) {
                                perror("rmdir");
                                retval = 1;
                        }
                        /* all done, we can exit the loop early. */
                        i = 0;
                } else {
                        int j, external_command_length;
                        char *external_command;
                        char *spaces;

                        external_command_length = strlen(COMMAND_MPLAYER) +5;
                        external_command = malloc(external_command_length);
                        strcpy(external_command, COMMAND_MPLAYER);
                        for (j = 1; j < argc; j++) {
                                external_command_length += 1 +strlen(argv[j]);
                                external_command = realloc(external_command, 
external_command_length);
                                strcat(external_command, " ");
                                /* this should fix argv with spaces in it. it's 
ugly I know */
                                spaces = strstr(argv[j], " ");
                                if (spaces) {
                                        strcat(external_command, "\"");
                                        strcat(external_command, argv[j]);
                                        strcat(external_command, "\"");
                                } else {
                                        strcat(external_command, argv[j]);
                                }
                        }
                        printf("extcmd: %s\n", external_command);
                        if (system(external_command)) {
                                perror("system");
                                retval = 1;
                        }
                }
        }
        return retval;
}

Reply via email to