musiclist - flashchat music adder, add music into list.xml

c, c++, php, html, sql ..etc discussion. also includes codes and source codes.
Post Reply
User avatar
Sethioz
Admin
Admin
Posts: 4762
Joined: Fri Jul 27, 2007 5:11 pm
Custom: Gaming YT > https://youtube.com/SethiozEntertainment
Game Hacking YT > https://youtube.com/sethioz
Game Hacks Store > https://sethioz.com/shopz
Location: unknown
Contact:

musiclist - flashchat music adder, add music into list.xml

Post by Sethioz »

i wanted to update my music list in mp3 player, the one that is inside of my flashchat, but i really couldnt bother to add them one by one. so i asked A.Luigi if he can help with it. he wrote a quick program that can do just that.
theres things you need to keep in mind!
the input file has to be in the following format:

Code: Select all

/flam_player/mp3/Amy Holland - She's On Fire.mp3
/flam_player/mp3/Angel City - Back In Time.mp3
/flam_player/mp3/Angel City - Calling You.mp3
Thats because he wrote it for me :) and i sent him my music.txt file which contained mp3 files in the format which i copyd them from my FTP. important is to get files into .xml format. later you can use replace to replace the path of the file into whtever you want. in my server the path looks like this:

Code: Select all

<song src="../../../../flam_player/mp3/Above & Beyond - Alone Tonight.mp3">
so you can do replace and replace the "../../../../flam_player/mp3/" part with whtever you want.

here's the code if you want to make any changes to it. for example i had to adjust the "new line" at end of file, because flashchat is gay and it fucks up when its missing new line or if theres too many new lines.

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void std_err(void) {
    perror("\nError");
    exit(1);
}

int main(int argc, char *argv[]) {
    FILE    *fd,
            *fdo;
    char    buff[1000],
            *p,
            *title,
            *artist;

    if(argc < 3) {
        printf("\n"
            "Usage: %s <music.txt> <output.XML>\n"
            "\n", argv[0]);
        exit(1);
    }

    fd = fopen(argv[1], "rb");
    if(!fd) std_err();
    fdo = fopen(argv[2], "wb");
    if(!fd) std_err();

    fprintf(fdo,
        "<?xml version=\"1.0\"?>\r\n"
        "<main>\r\n");

    while(fgets(buff, sizeof(buff), fd)) {
        for(p = buff; *p && (*p != '\n') && (*p != '\r'); p++);
        *p = 0;

        if(!buff[0]) continue;

        fprintf(fdo,
            "\t<song src=\"../../../..%s\">\r\n",
            buff);

        title  = "";
        artist = "";

        p = strstr(buff, " - ");
        if(!p) p = strstr(buff, "_-_");
        if(p) {
            *p = 0;
            title = p + 3;
            p = strrchr(title, '.');
            if(p) *p = 0;
            p = strrchr(buff, '/');
            if(p) artist = p + 1;
        }

        fprintf(fdo, 
            "\t\t<title>%s</title>\r\n"
            "\t\t<artist>%s</artist>\r\n"
            "\t\t<genre></genre>\r\n"
            "\t\t<duration></duration>\r\n"
            "\t</song>\r\n",
            artist,
            title);
    }

    fprintf(fdo, "\r\n\r\n</main>");

    fclose(fd);
    fclose(fdo);
    printf("- done\n");
    return(0);
}

Here, i also compiled it and added the exe.[/color]

Anyways, thanks Luigi :)
Attachments
musiclist.rar
(4.96 KiB) Downloaded 637 times
Post Reply