Skip to content

Commit 7a98d5c

Browse files
author
WMFO Administrator
committed
add scripts, fix bug, remove logging
1 parent 6bee007 commit 7a98d5c

File tree

6 files changed

+148
-0
lines changed

6 files changed

+148
-0
lines changed

hour-mator/hour-mator.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include <stdio.h>
2+
#include <time.h>
3+
#include <string.h>
4+
#include <fcntl.h>
5+
#include <string.h>
6+
7+
#define BUFSIZE 4*48000 //1s at 2 channels * 2 bytes/sample * 2 bytes/unsigned short
8+
9+
10+
char newtime[100], curtime[100];
11+
12+
struct tm tptr;
13+
time_t t;
14+
FILE *f = NULL;
15+
16+
void switch_file();
17+
18+
int main()
19+
{
20+
/*printf("Int is %d", sizeof(unsigned short));
21+
return 0;*/
22+
int fd;
23+
int c;
24+
//unsigned long reads_remaining;
25+
unsigned short buffer[BUFSIZE + 1];
26+
27+
while (1) {
28+
switch_file();
29+
c = fread(buffer, sizeof(unsigned short), BUFSIZE, stdin);
30+
//printf("%d bytes read", c);
31+
fwrite(buffer, sizeof(unsigned short), c, f);
32+
}
33+
//printf("Done reading");
34+
35+
return 0;
36+
}
37+
38+
void switch_file() {
39+
//printf("switching file");
40+
char filename[100];
41+
42+
t = time(NULL);
43+
44+
gmtime_r(&t, &tptr);
45+
46+
strftime(newtime, 100, "%Y-%m-%d_%HU", &tptr);
47+
//printf("%s", newtime);
48+
if (strncmp(curtime, newtime, 100) != 0) {
49+
if (f != NULL)
50+
fclose(f);
51+
strncpy(curtime,newtime,100);
52+
snprintf(filename,100,"/home/wmfo-admin/archives/%s.s16",curtime);
53+
f = fopen(filename, "a");
54+
}
55+
56+
return;
57+
}
58+

scripts/convert-mp3.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
file=$1
4+
5+
if [ -z "$1" ] ; then
6+
echo Usage: $0 FILENAMES_FILE
7+
exit 1
8+
fi
9+
10+
while read input_file; do
11+
output_file="${input_file%.mp3}.m4a"
12+
# echo $input_file $output_file
13+
# need to redirect input to /dev/null or else stdin contention with loop
14+
./ffmpeg -i $input_file -c:a libfdk_aac -b:a 128k $output_file < /dev/null
15+
#exit 1
16+
done < $file

scripts/convert-s16.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
file=$1
4+
5+
if [ -z "$1" ] ; then
6+
echo Usage: $0 FILENAMES_FILE
7+
exit 1
8+
fi
9+
10+
while read input_file; do
11+
# echo $input_file $output_file
12+
# need to redirect input to /dev/null or else stdin contention with loop
13+
output_file="${input_file%.s16}.m4a"
14+
./ffmpeg -f s16le -ar 48000 -ac 2 -i $input_file -c:a libfdk_aac -b:a 128k $output_file < /dev/null
15+
#exit 1
16+
done < $file

scripts/fix_underscore.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
file=$1
4+
5+
if [ -z "$1" ] ; then
6+
echo Usage: $0 FILENAMES_FILE
7+
exit 1
8+
fi
9+
10+
while read input_file; do
11+
output_file=`echo "$input_file" | sed 's/-\([0-9]*\)\.m4a/_\1\.m4a/g'`
12+
echo $input_file $output_file
13+
mv $input_file $output_file
14+
done < $file

scripts/utc-mv.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
file=$1
4+
5+
if [ -z "$1" ] ; then
6+
echo Usage: $0 FILENAMES_FILE
7+
exit 1
8+
fi
9+
10+
while read input_file; do
11+
input_filename=$(basename $input_file)
12+
input_extension=${input_filename##*.}
13+
input_basefilename=${input_filename%.*}
14+
input_directory=$(dirname $input_file)
15+
input_date=`echo "$input_basefilename:00:00" | sed 's/_/ /g'`
16+
output_filename_base=`date -d "$input_date" +@%s | xargs date -u +%Y-%m-%d_%HU -d`
17+
output_filename=`echo $input_directory/$output_filename_base.$input_extension`
18+
#output_file=`echo "$input_file" | sed 's/-\([0-9]*\)\.m4a/_\1\.m4a/g'`
19+
echo $input_file $output_filename
20+
mv -n $input_file $output_filename
21+
done < $file

scripts/utc-symlink.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
3+
file=$1
4+
5+
if [ -z "$1" ] ; then
6+
echo Usage: $0 FILENAMES_FILE
7+
exit 1
8+
fi
9+
10+
while read input_file; do
11+
input_filename=$(basename $input_file)
12+
input_extension=${input_filename##*.}
13+
input_basefilename=${input_filename%.*}
14+
input_directory=$(dirname $input_file)
15+
input_date=`echo "$input_basefilename:00:00" | sed 's/_/ /g'`
16+
output_filename_base=`date -d "$input_date" +@%s | xargs date -u +%Y-%m-%d_%HU -d`
17+
output_filename=`echo $input_directory/$output_filename_base.$input_extension`
18+
#output_file=`echo "$input_file" | sed 's/-\([0-9]*\)\.m4a/_\1\.m4a/g'`
19+
echo $input_file $output_filename
20+
unlink $output_filename
21+
#ln -s $input_file $output_filename
22+
#mv $input_file $output_file
23+
done < $file

0 commit comments

Comments
 (0)