2022-04-17 11:39:48 +00:00
|
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
|
|
int irmode=0;
|
2022-04-17 11:41:25 +00:00
|
|
|
|
void DLFhandler(dlf* dl,size_t real){
|
|
|
|
|
//max fat32 is 4,294,967,000 just to be safe
|
|
|
|
|
size_t bytesnow = ftell(dl->fp) + real;
|
|
|
|
|
|
|
|
|
|
if(bytesnow >= (size_t)4294967000){
|
|
|
|
|
dl->fileid++;
|
|
|
|
|
char nam[1008];
|
|
|
|
|
|
|
|
|
|
sprintf(nam,"%s.%i",dl->fnam,dl->fileid);
|
|
|
|
|
freopen(nam,"wb",dl->fp);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-17 11:39:48 +00:00
|
|
|
|
int UsingIRFeatures(){
|
|
|
|
|
return irmode;
|
|
|
|
|
}
|
|
|
|
|
void SwitchIR(){
|
|
|
|
|
if(irmode==0){irmode=1;}else{irmode=0;}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
FILE* HistoryRead(){
|
|
|
|
|
return fopen("/TYTD/history.txt","r");
|
|
|
|
|
}
|
|
|
|
|
FILE* HistoryAppend(){
|
|
|
|
|
return fopen("/TYTD/history.txt","aw");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FILE* PlaylistTXT(char* fil){
|
|
|
|
|
char file2[500];
|
|
|
|
|
sprintf(file2,"/TYTD/PLTXT/%s.txt",fil);
|
|
|
|
|
return fopen(file2,"r");
|
|
|
|
|
}
|
|
|
|
|
int FileSystemDrivers(){
|
|
|
|
|
fatInitDefault();
|
|
|
|
|
USBStorage_Initialize();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
char* OpenVideoFile(char* filename){
|
|
|
|
|
|
|
|
|
|
char *yt = malloc(sizeof(char)*530);
|
|
|
|
|
snprintf(yt,530,"/TYTD/Videos/%s.mp4",filename);
|
|
|
|
|
|
|
|
|
|
return yt;
|
|
|
|
|
}
|
|
|
|
|
void OpenPlaylistFile(char* playlist){
|
|
|
|
|
|
|
|
|
|
char yt[820];
|
|
|
|
|
snprintf(yt,820,"/TYTD/Videos/%s",playlist);
|
|
|
|
|
mkdir(yt,0777);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
char* OpenFile(char* fname2){
|
|
|
|
|
char filename[720];
|
|
|
|
|
char *yt = malloc(sizeof(char)*820);
|
|
|
|
|
char timein[20];
|
|
|
|
|
time_t now = time(0);
|
|
|
|
|
strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now));
|
|
|
|
|
snprintf(filename,720, fname2,timein);
|
|
|
|
|
snprintf(yt,820,"/TYTD/Downloads/%s",filename);
|
|
|
|
|
|
|
|
|
|
return yt;
|
|
|
|
|
}
|
|
|
|
|
char* OpenPlaylistVideoFile(char* playlist,char* video){
|
|
|
|
|
|
|
|
|
|
char *yt = malloc(sizeof(char)*820);
|
|
|
|
|
snprintf(yt,820,"/TYTD/Videos/%s/%s.mp4",playlist,video);
|
|
|
|
|
|
|
|
|
|
return yt;
|
|
|
|
|
}
|
|
|
|
|
char* ThumbnailFileName(char* filename){
|
|
|
|
|
|
|
|
|
|
char *yt = malloc(sizeof(char) *530);
|
|
|
|
|
snprintf(yt,530,"/TYTD/Thumbnails/%s.jpg",filename);
|
|
|
|
|
|
|
|
|
|
return yt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int ThumbnailExists(char* filename){
|
|
|
|
|
char yt[530];
|
|
|
|
|
snprintf(yt,530,"/TYTD/Thumbnails/%s.jpg",filename);
|
|
|
|
|
struct stat buffer;
|
|
|
|
|
return (stat(yt,&buffer)==0);
|
|
|
|
|
}
|
|
|
|
|
char* ThumbnailURL(char* id){
|
|
|
|
|
char *yt = malloc(sizeof(char) *530);
|
|
|
|
|
sprintf(yt,"https://img.youtube.com/vi/%s/hqdefault.jpg",id);
|
|
|
|
|
return yt;
|
|
|
|
|
}
|
|
|
|
|
int CreateFolders(){
|
|
|
|
|
mkdir("/TYTD",0777); //Downloader
|
|
|
|
|
mkdir("/TYTD/Thumbnails",0777); //Thumbnails
|
|
|
|
|
mkdir("/TYTD/Downloads",0777); //Downloads
|
|
|
|
|
mkdir("/TYTD/Videos",0777); //Videos
|
|
|
|
|
mkdir("/TYTD/PLTXT",0777); //create dir for playlist text files
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char* Temp(){
|
|
|
|
|
char *yt = malloc(sizeof(char)*530);
|
|
|
|
|
snprintf(yt,530,"/TYTD/~TMP");
|
|
|
|
|
|
|
|
|
|
return yt;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DeleteTemp(){
|
|
|
|
|
unlink("/TYTD/~TMP");
|
|
|
|
|
}
|