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

View File

@ -1,6 +1,7 @@
#ifndef COLORS_H
#define COLORS_H
#include "settings.h"
//get gui color
u32 GetColor(int component);
static const int DOWNLOAD_BACKGROUND=0; // Originaly Red
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_KEYBOARD_OUTLINE=12; //Originaly Violet
#define TOTALCOLORS 13
//set gui color
void SetColor(u32 color,int component);
//set scheme
void InitColor(int scheme);
//cycle through color schemes
int AddScheme(int val);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,12 @@
#include "settings.h"
char root[35];
//contains file helper functions
extern bool allowredownloadscreen;
extern void Download4(char*,char*,int);
void SetRoot(char* rootdir){
sprintf(root,"%s",rootdir);
TempVal = Temp();
}
int irmode=0;
char* FileNameParse(char* path) {
char* yt = malloc(sizeof(char) * 530);
@ -9,6 +16,7 @@ for(size_t i = len-1;path[i] != '/';i--){
pos = i;
}
for(size_t i = pos;i<=len;i++){
size_t ind = i - pos;
yt[ind] = path[i];
@ -16,17 +24,50 @@ for(size_t i = pos;i<=len;i++){
}
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){
//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){
dl->fileid++;
char nam[1008];
//if(bytesnow >= (size_t)4294967000){
// dl->fileid++;
//char nam[1008];
sprintf(nam,"%s.%i",dl->fnam,dl->fileid);
freopen(nam,"wb",dl->fp);
}
// sprintf(nam,"%s.%i",dl->fnam,dl->fileid);
// freopen(nam,"wb",dl->fp);
// }
}
int UsingIRFeatures(){
return irmode;
@ -37,26 +78,39 @@ void SwitchIR(){
FILE* HistoryRead(){
return fopen("/TYTD/history.txt","r");
char history[38];
sprintf(history,"%s:/TYTD/history.txt",root);
return fopen(history,"r");
}
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){
char file2[500];
sprintf(file2,"/TYTD/PLTXT/%s",fil);
sprintf(file2,"%s:/TYTD/PLTXT/%s",root,fil);
return fopen(file2,"r");
}
void CreatePL(char* fil){
char file2[500];
sprintf(file2,"/TYTD/PLTXT/%s",fil);
sprintf(file2,"%s:/TYTD/PLTXT/%s",root,fil);
FILE *f =fopen(file2,"w");
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){
char file2[500];
sprintf(file2,"/TYTD/PLTXT/%s",fil);
sprintf(file2,"%s:/TYTD/PLTXT/%s",root,fil);
FILE *f =fopen(file2,"a");
fseek(f,0,SEEK_END);
@ -67,24 +121,56 @@ fprintf(f,"\n%s %s %s",type,url,filename);
}
fclose(f);
}
int FileSystemDrivers(){
fatInitDefault();
/*
typedef struct disks{
int ntfsusbs;
int ntfssds;
bool hassd;
bool hasusb;
bool hasfatsd;
bool hasfatusb;
}disks;
*/
disks* FileSystemDrivers(){
disks *d = malloc(sizeof(disks));
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 *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;
}
void OpenPlaylistFile(char* playlist){
char yt[820];
snprintf(yt,820,"/TYTD/Videos/%s",playlist);
snprintf(yt,820,"%s:/TYTD/Videos/%s",root,playlist);
mkdir(yt,0777);
char yt2[820];
snprintf(yt2,820,"%s:/TYTD/Desc/%s",root,playlist);
mkdir(yt2,0777);
}
char* OpenFile(char* fname2){
@ -94,21 +180,42 @@ char* OpenFile(char* fname2){
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);
snprintf(yt,820,"%s:/TYTD/Downloads/%s",root,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);
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;
}
char* ThumbnailFileName(char* filename){
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;
}
@ -116,7 +223,7 @@ snprintf(yt,530,"/TYTD/Thumbnails/%s.jpg",filename);
int ThumbnailExists(char* filename){
char yt[530];
snprintf(yt,530,"/TYTD/Thumbnails/%s.jpg",filename);
snprintf(yt,530,"%s:/TYTD/Thumbnails/%s.jpg",root,filename);
struct stat buffer;
return (stat(yt,&buffer)==0);
}
@ -125,24 +232,50 @@ char* ThumbnailURL(char* id){
sprintf(yt,"https://img.youtube.com/vi/%s/hqdefault.jpg",id);
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(){
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
char tytddir[27];
char tytdtn[49];
char tytddl[48];
char tytdvi[45];
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;
}
char* Temp(){
char *yt = malloc(sizeof(char)*530);
snprintf(yt,530,"/TYTD/~TMP");
snprintf(yt,530,"%s:/TYTD/~TMP",root);
return yt;
}
char* PLTXTDIR()
{
char *yt = malloc(sizeof(char)*530);
snprintf(yt,530,"%s:/TYTD/PLTXT/",root);
return yt;
void DeleteTemp(){
unlink("/TYTD/~TMP");
}
void DeleteTemp(){
unlink(Temp());
}

View File

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