Skip to content

Commit 3c798f5

Browse files
committed
feat: Change Recording Schedule
1 parent d176ee1 commit 3c798f5

File tree

2 files changed

+29
-36
lines changed

2 files changed

+29
-36
lines changed

cmd/yt-upload-v2/main.go

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616

1717
type File struct {
1818
Name string
19+
Size int64
1920
FullPath string
2021
BasePath string
2122
Uploaded bool
@@ -96,28 +97,33 @@ func refreshFileList() {
9697

9798
var refreshedFileList []File
9899

99-
for _, f := range folders {
100-
fileBasePath := fmt.Sprintf("%s/%s", root, f.Name())
101-
fs, err := os.ReadDir(fileBasePath)
102-
if err != nil {
103-
log.Fatal(err)
104-
}
100+
for _, file := range folders {
101+
fullPath := fmt.Sprintf("%s/%s", root, file.Name())
105102

106-
for _, file := range fs {
107-
fullPath := fmt.Sprintf("%s/%s/%s", root, f.Name(), file.Name())
103+
if strings.HasSuffix(file.Name(), ".mkv") {
104+
uploaded := false
105+
if _, err := os.Stat(fmt.Sprintf("%s/.%s-uploaded", root, file.Name())); err == nil {
106+
uploaded = true
107+
}
108108

109-
if strings.HasSuffix(file.Name(), ".mkv") {
110-
uploaded := false
111-
if _, err := os.Stat(fmt.Sprintf("%s/.%s-uploaded", fileBasePath, file.Name())); err == nil {
112-
uploaded = true
113-
}
114-
refreshedFileList = append(refreshedFileList, File{
115-
Name: file.Name(),
116-
BasePath: fileBasePath,
117-
FullPath: fullPath,
118-
Uploaded: uploaded,
119-
})
109+
fileInfo, err := file.Info()
110+
if err != nil {
111+
continue
120112
}
113+
114+
// If size is smaller than 5 MegaByte, skip for now (is 0 if still not uploaded; skipping bad videos too)
115+
if fileInfo.Size() < 5<<20 {
116+
fmt.Printf("%s video too small, don't think should upload (%d bytes)\n", file.Name(), fileInfo.Size())
117+
continue
118+
}
119+
120+
refreshedFileList = append(refreshedFileList, File{
121+
Name: file.Name(),
122+
Size: fileInfo.Size(),
123+
BasePath: root,
124+
FullPath: fullPath,
125+
Uploaded: uploaded,
126+
})
121127
}
122128
}
123129

rec/rec_iqama.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,14 @@ func (rc *RecordConfigDataS) Refresh() {
7070
{
7171
Description: "Isha Recording",
7272
StartTime: toTime(iqamaTimes.Isha.Iqama),
73-
Duration: DarsRecordDuration,
74-
RecordingDays: EveryDay,
75-
},
76-
77-
{
78-
Description: "Thursday Fiqh Dars Recording",
79-
StartTime: toTime(iqamaTimes.Maghrib.Iqama),
8073
Duration: JumuaaRecordDuration,
81-
RecordingDays: []time.Weekday{time.Thursday},
82-
},
83-
{
84-
Description: "Monday Maghrib Dars Recording",
85-
StartTime: toTime(iqamaTimes.Maghrib.Iqama),
86-
Duration: JumuaaRecordDuration,
87-
RecordingDays: []time.Weekday{time.Monday},
74+
RecordingDays: EveryDay,
8875
},
8976
{
90-
Description: "Sunday Isha Dars Recording",
91-
StartTime: toTime(iqamaTimes.Maghrib.Iqama),
77+
Description: "Jumuaa Recording",
78+
StartTime: time.Date(2023, 1, 1, 11, 55, 0, 0, timeLocation),
9279
Duration: JumuaaRecordDuration,
93-
RecordingDays: []time.Weekday{time.Sunday},
80+
RecordingDays: []time.Weekday{time.Friday},
9481
},
9582
}
9683
}

0 commit comments

Comments
 (0)