5-1-2020 (wasnt in git)

This commit is contained in:
Michael Nolan 2022-04-17 06:46:26 -05:00
parent 5d8203e27b
commit 7ac8fd8b29
5 changed files with 885 additions and 135 deletions

View File

@ -83,7 +83,7 @@ u32 GetColor(int component){
void SetColor(u32 color,int component){ void SetColor(u32 color,int component){
colors[component] = color; colors[component] = color;
} }
//init scheme set colors
void InitColor(int scheme){ void InitColor(int scheme){
//Type Colors //Type Colors
switch(scheme){ switch(scheme){
@ -105,6 +105,7 @@ case 3:
break; break;
} }
} }
//cycle through schemes
int AddScheme(int val){ int AddScheme(int val){
if (val<(s-1)){ if (val<(s-1)){
return val+1; return val+1;

View File

@ -1,6 +1,7 @@
#ifndef COLORS_H #ifndef COLORS_H
#define COLORS_H #define COLORS_H
#include "settings.h" #include "settings.h"
//get gui color
u32 GetColor(int component); u32 GetColor(int component);
static const int DOWNLOAD_BACKGROUND=0; // Originaly Red static const int DOWNLOAD_BACKGROUND=0; // Originaly Red
static const int DOWNLOAD_TEXTBOX_BACKGROUND=1; //Originaly White static const int DOWNLOAD_TEXTBOX_BACKGROUND=1; //Originaly White
@ -16,7 +17,10 @@ static const int DOWNLOAD_PROGRESSVAL=10; //Originaly Blue
static const int DOWNLOAD_SELECTOR=11; //Originaly Green static const int DOWNLOAD_SELECTOR=11; //Originaly Green
static const int DOWNLOAD_KEYBOARD_OUTLINE=12; //Originaly Violet static const int DOWNLOAD_KEYBOARD_OUTLINE=12; //Originaly Violet
#define TOTALCOLORS 13 #define TOTALCOLORS 13
//set gui color
void SetColor(u32 color,int component); void SetColor(u32 color,int component);
//set scheme
void InitColor(int scheme); void InitColor(int scheme);
//cycle through color schemes
int AddScheme(int val); int AddScheme(int val);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,21 @@
#include "settings.h" #include "settings.h"
char root[35];
int irmode=0; //contains file helper functions
char* FileNameParse(char* path){ extern bool allowredownloadscreen;
char *yt = malloc(sizeof(char)*530); extern void Download4(char*,char*,int);
size_t len = strlen(path); void SetRoot(char* rootdir){
size_t pos=0; sprintf(root,"%s",rootdir);
for(size_t i = len-1;path[i] != '/';i--){ TempVal = Temp();
pos = i;
} }
int irmode=0;
char* FileNameParse(char* path) {
char* yt = malloc(sizeof(char) * 530);
size_t len = strlen(path);
size_t pos = 0;
for (size_t i = len - 1; path[i] != '/'; i--) {
pos = i;
}
for(size_t i = pos;i<=len;i++){ for(size_t i = pos;i<=len;i++){
size_t ind = i - pos; size_t ind = i - pos;
@ -16,17 +24,50 @@ for(size_t i = pos;i<=len;i++){
} }
return yt; return yt;
} }
void DownloadThumbnailsAlt(char* id, int point) {
bool redowsc = allowredownloadscreen;
allowredownloadscreen = false;
char img0[25];
snprintf(img0, 25, "%s_480_360", id);
char img1[25];
snprintf(img1, 25, "%s_120_90", id);
char defaultimg[25];
snprintf(defaultimg, 25, "%s_default", id);
char mqdefault[25];
snprintf(mqdefault, 25, "%s_mqdefault", id);
char hqdefault[25];
snprintf(hqdefault, 25, "%s_hqdefault", id);
char sddefault[25];
snprintf(sddefault, 25, "%s_sddefault", id);
char maxresdefault[29];
snprintf(maxresdefault, 29, "%s_maxresdefault", id);
if (!ThumbnailExists(img0)) { Download4(ThumbnailURLAlt(id, "0"), ThumbnailFileName(img0), point); }
if (!ThumbnailExists(img1)) { Download4(ThumbnailURLAlt(id, "1"), ThumbnailFileName(img1), point); }
if (!ThumbnailExists(defaultimg)) { Download4(ThumbnailURLAlt(id, "default"), ThumbnailFileName(defaultimg), point); }
if (!ThumbnailExists(mqdefault)) { Download4(ThumbnailURLAlt(id, "mqdefault"), ThumbnailFileName(mqdefault), point); }
if (!ThumbnailExists(hqdefault)) { Download4(ThumbnailURLAlt(id, "hqdefault"), ThumbnailFileName(hqdefault), point); }
if (!ThumbnailExists(sddefault)) { Download4(ThumbnailURLAlt(id, "sddefault"), ThumbnailFileName(sddefault), point); }
if (!ThumbnailExists(maxresdefault)) { Download4(ThumbnailURLAlt(id, "maxresdefault"), ThumbnailFileName(maxresdefault), point); }
allowredownloadscreen = redowsc;
}
void DLFhandler(dlf* dl,size_t real){ void DLFhandler(dlf* dl,size_t real){
//max fat32 is 4,294,967,000 just to be safe //max fat32 is 4,294,967,000 just to be safe
size_t bytesnow = ftell(dl->fp) + real; // size_t bytesnow = ftell(dl->fp) + real;
if(bytesnow >= (size_t)4294967000){ //if(bytesnow >= (size_t)4294967000){
dl->fileid++; // dl->fileid++;
char nam[1008]; //char nam[1008];
sprintf(nam,"%s.%i",dl->fnam,dl->fileid); // sprintf(nam,"%s.%i",dl->fnam,dl->fileid);
freopen(nam,"wb",dl->fp); // freopen(nam,"wb",dl->fp);
} // }
} }
int UsingIRFeatures(){ int UsingIRFeatures(){
return irmode; return irmode;
@ -37,27 +78,40 @@ void SwitchIR(){
FILE* HistoryRead(){ FILE* HistoryRead(){
return fopen("/TYTD/history.txt","r"); char history[38];
sprintf(history,"%s:/TYTD/history.txt",root);
return fopen(history,"r");
} }
FILE* HistoryAppend(){ FILE* HistoryAppend(){
return fopen("/TYTD/history.txt","aw"); char history[38];
sprintf(history,"%s:/TYTD/history.txt",root);
return fopen(history,"aw");
} }
FILE* PlaylistTXT(char* fil){ FILE* PlaylistTXT(char* fil){
char file2[500]; char file2[500];
sprintf(file2,"/TYTD/PLTXT/%s",fil); sprintf(file2,"%s:/TYTD/PLTXT/%s",root,fil);
return fopen(file2,"r"); return fopen(file2,"r");
} }
void CreatePL(char* fil){ void CreatePL(char* fil){
char file2[500]; char file2[500];
sprintf(file2,"/TYTD/PLTXT/%s",fil); sprintf(file2,"%s:/TYTD/PLTXT/%s",root,fil);
FILE *f =fopen(file2,"w"); FILE *f =fopen(file2,"w");
fclose(f); fclose(f);
} }
char* CreatePL2(char* fil){
char *file2 = malloc(sizeof(char)*530);
sprintf(file2,"%s:/TYTD/PLTXT/%s",root,fil);
return file2;
}
void WriteFile2PL(char* fil,char* type,char* url,char* filename){ void WriteFile2PL(char* fil,char* type,char* url,char* filename){
char file2[500]; char file2[500];
sprintf(file2,"/TYTD/PLTXT/%s",fil); sprintf(file2,"%s:/TYTD/PLTXT/%s",root,fil);
FILE *f =fopen(file2,"a"); FILE *f =fopen(file2,"a");
fseek(f,0,SEEK_END); fseek(f,0,SEEK_END);
if(ftell(f) == 0L){ if(ftell(f) == 0L){
@ -67,24 +121,56 @@ fprintf(f,"\n%s %s %s",type,url,filename);
} }
fclose(f); fclose(f);
} }
/*
int FileSystemDrivers(){ typedef struct disks{
fatInitDefault(); int ntfsusbs;
int ntfssds;
bool hassd;
bool hasusb;
bool hasfatsd;
bool hasfatusb;
}disks;
*/
disks* FileSystemDrivers(){
disks *d = malloc(sizeof(disks));
USBStorage_Initialize(); USBStorage_Initialize();
return 0;
fatInitDefault();
DIR *sdcarddisk =opendir("sd:/");
DIR *usbdisk = opendir("usb:/");
if(sdcarddisk){
closedir(sdcarddisk);
d->sdfat=TRUE;
}else{
d->sdfat=FALSE;
}
if(usbdisk){
closedir(usbdisk);
d->usbfat=TRUE;
}else{
d->usbfat=FALSE;
}
d->ntfsv=NULL;
d->ntfsc=ntfsMountAll (&d->ntfsv,NTFS_DEFAULT | NTFS_RECOVER);
return d;
} }
char* OpenVideoFile(char* filename){ char* OpenVideoFile(char* filename){
char *yt = malloc(sizeof(char)*530); char *yt = malloc(sizeof(char)*530);
snprintf(yt,530,"/TYTD/Videos/%s.mp4",filename); snprintf(yt,530,"%s:/TYTD/Videos/%s.mp4",root,filename);
return yt; return yt;
} }
void OpenPlaylistFile(char* playlist){ void OpenPlaylistFile(char* playlist){
char yt[820]; char yt[820];
snprintf(yt,820,"/TYTD/Videos/%s",playlist); snprintf(yt,820,"%s:/TYTD/Videos/%s",root,playlist);
mkdir(yt,0777); mkdir(yt,0777);
char yt2[820];
snprintf(yt2,820,"%s:/TYTD/Desc/%s",root,playlist);
mkdir(yt2,0777);
} }
char* OpenFile(char* fname2){ char* OpenFile(char* fname2){
@ -94,21 +180,42 @@ char* OpenFile(char* fname2){
time_t now = time(0); time_t now = time(0);
strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now)); strftime(timein, sizeof(timein), "%Y%m%d_%H%M%S", localtime(&now));
snprintf(filename,720, fname2,timein); snprintf(filename,720, fname2,timein);
snprintf(yt,820,"/TYTD/Downloads/%s",filename); snprintf(yt,820,"%s:/TYTD/Downloads/%s",root,filename);
return yt; return yt;
} }
char* OpenPlaylistVideoFile(char* playlist,char* video){ char* OpenPlaylistVideoFile(char* playlist,char* video){
char *yt = malloc(sizeof(char)*820); char *yt = malloc(sizeof(char)*820);
snprintf(yt,820,"/TYTD/Videos/%s/%s.mp4",playlist,video); snprintf(yt,820,"%s:/TYTD/Videos/%s/%s.mp4",root,playlist,video);
return yt;
}
char* OpenPlaylistDescFile(char* playlist,char* video){
char *yt = malloc(sizeof(char)*820);
snprintf(yt,820,"%s:/TYTD/Desc/%s/%s.txt",root,playlist,video);
return yt;
}
char* OpenDescFile(char* video){
char *yt = malloc(sizeof(char)*820);
snprintf(yt,820,"%s:/TYTD/Desc/%s.txt",root,video);
return yt;
}
char* AppConfig(){
char *yt = malloc(sizeof(char)*820);
snprintf(yt,820,"%s:/TYTD/config.xml",root);
return yt; return yt;
} }
char* ThumbnailFileName(char* filename){ char* ThumbnailFileName(char* filename){
char *yt = malloc(sizeof(char) *530); char *yt = malloc(sizeof(char) *530);
snprintf(yt,530,"/TYTD/Thumbnails/%s.jpg",filename); snprintf(yt,530,"%s:/TYTD/Thumbnails/%s.jpg",root,filename);
return yt; return yt;
} }
@ -116,7 +223,7 @@ snprintf(yt,530,"/TYTD/Thumbnails/%s.jpg",filename);
int ThumbnailExists(char* filename){ int ThumbnailExists(char* filename){
char yt[530]; char yt[530];
snprintf(yt,530,"/TYTD/Thumbnails/%s.jpg",filename); snprintf(yt,530,"%s:/TYTD/Thumbnails/%s.jpg",root,filename);
struct stat buffer; struct stat buffer;
return (stat(yt,&buffer)==0); return (stat(yt,&buffer)==0);
} }
@ -125,24 +232,50 @@ char* ThumbnailURL(char* id){
sprintf(yt,"https://img.youtube.com/vi/%s/hqdefault.jpg",id); sprintf(yt,"https://img.youtube.com/vi/%s/hqdefault.jpg",id);
return yt; return yt;
} }
char* ThumbnailURLAlt(char* id,char* res){
char *yt = malloc(sizeof(char) *530);
sprintf(yt,"https://img.youtube.com/vi/%s/%s.jpg",id,res);
return yt;
}
int CreateFolders(){ int CreateFolders(){
mkdir("/TYTD",0777); //Downloader char tytddir[27];
mkdir("/TYTD/Thumbnails",0777); //Thumbnails char tytdtn[49];
mkdir("/TYTD/Downloads",0777); //Downloads char tytddl[48];
mkdir("/TYTD/Videos",0777); //Videos char tytdvi[45];
mkdir("/TYTD/PLTXT",0777); //create dir for playlist text files char tytdpl[44];
char tytddes[45];
sprintf(tytddir,"%s:/TYTD",root);
sprintf(tytddl,"%s/Downloads",tytddir);
sprintf(tytdtn,"%s/Thumbnails",tytddir);
sprintf(tytdvi,"%s/Videos",tytddir);
sprintf(tytdpl,"%s/PLTXT",tytddir);
sprintf(tytddes,"%s/Desc",tytddir);
mkdir(tytddir,0777); //Downloader
mkdir(tytdtn,0777); //Thumbnails
mkdir(tytddl,0777); //Downloads
mkdir(tytdvi,0777); //Videos
mkdir(tytddes,0777); //Desc
mkdir(tytdpl,0777); //create dir for playlist text files
return 0; return 0;
} }
char* Temp(){ char* Temp(){
char *yt = malloc(sizeof(char)*530); char *yt = malloc(sizeof(char)*530);
snprintf(yt,530,"/TYTD/~TMP"); snprintf(yt,530,"%s:/TYTD/~TMP",root);
return yt; return yt;
} }
char* PLTXTDIR()
{
char *yt = malloc(sizeof(char)*530);
snprintf(yt,530,"%s:/TYTD/PLTXT/",root);
void DeleteTemp(){ return yt;
unlink("/TYTD/~TMP");
}
void DeleteTemp(){
unlink(Temp());
} }

View File

@ -9,16 +9,27 @@
#include <fat.h> #include <fat.h>
#include <unistd.h> #include <unistd.h>
#include <ogc/usbstorage.h> #include <ogc/usbstorage.h>
#include <ntfs.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <wiiuse/wpad.h> #include <wiiuse/wpad.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <sdcard/wiisd_io.h>
#include <curl/curl.h> #include <curl/curl.h>
#include <grrlib.h> #include <grrlib.h>
#include "FreeMonoBold_ttf.h" #include "FreeMonoBold_ttf.h"
extern int net_init();
extern char* TempVal;
typedef struct disks{
int ntfsc;
bool sdfat;
bool usbfat;
ntfs_md *ntfsv;
}disks;
typedef struct dlf{ typedef struct dlf{
FILE* fp; FILE* fp;
char fnam[1000]; char fnam[1000];
@ -26,26 +37,36 @@ typedef struct dlf{
int fileid; int fileid;
int fileindex; int fileindex;
}dlf; }dlf;
void SetRoot(char* rootdir);
char* FileNameParse(char* path); char* FileNameParse(char* path);
void DLFhandler(dlf* dl,size_t real); void DLFhandler(dlf* dl,size_t real);
void OpenPlaylistFile(char* playlist); void OpenPlaylistFile(char* playlist);
char* PLTXTDIR();
char* OpenFile(char* fname); char* OpenFile(char* fname);
char* OpenPlaylistVideoFile(char* playlist,char* video); char* OpenPlaylistVideoFile(char* playlist,char* video);
char* OpenPlaylistDescFile(char* playlist,char* video);
char* OpenDescFile(char* video);
FILE* HistoryRead(); FILE* HistoryRead();
FILE* HistoryAppend(); FILE* HistoryAppend();
int UsingIRFeatures(); int UsingIRFeatures();
int FileSystemDrivers(); disks* FileSystemDrivers();
void WriteFile2PL(char* fil,char* type,char* url,char* filename); void WriteFile2PL(char* fil,char* type,char* url,char* filename);
void CreatePL(char* fil); void CreatePL(char* fil);
char* CreatePL2(char* fil);
char* OpenVideoFile(char* filename); char* OpenVideoFile(char* filename);
char* ThumbnailFileName(char* filename); char* ThumbnailFileName(char* filename);
int ThumbnailExists(char* id); int ThumbnailExists(char* id);
int CreateFolders(); int CreateFolders();
char* ThumbnailURL(char* id); char* ThumbnailURL(char* id);
char* ThumbnailURLAlt(char* id,char* res);
FILE* PlaylistTXT(char* fil); FILE* PlaylistTXT(char* fil);
char* Temp(); char* Temp();
char* AppConfig();
void DeleteTemp(); void DeleteTemp();
void SwitchIR(); void SwitchIR();
#endif #endif