about summary refs log tree commit diff
path: root/laravel
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2021-09-28 16:05:12 +0000
committerZach DeCook <zachdecook@librem.one>2021-09-28 16:05:12 +0000
commit753593fe0d25a5cc58ca84fbbccc24bd9c6e6e1e (patch)
treecd7209b54ee4108ad943bc4db87746e7ab38e231 /laravel
parent0586163907a153ebe1d506d8040aa574a0b6e0f3 (diff)
downloadprosongsa-753593fe0d25a5cc58ca84fbbccc24bd9c6e6e1e.tar.gz
misc gemini additions
Diffstat (limited to 'laravel')
-rwxr-xr-xlaravel/applyedit.php13
-rwxr-xr-xlaravel/public/playlist.gmi3
-rwxr-xr-xlaravel/public/song.gmi.php2
3 files changed, 14 insertions, 4 deletions
diff --git a/laravel/applyedit.php b/laravel/applyedit.php
index b9aa619..bd9f296 100755
--- a/laravel/applyedit.php
+++ b/laravel/applyedit.php
@@ -8,12 +8,20 @@ $kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
 use App\Song;
 
 $imap = imap_open($mailbox, $username, $password);
+if (!$imap){
+    printf("no imap :(");
+    exit(1);
+}
 $check = imap_check($imap); $number = $check->Nmsgs;
+if (!$check){
+    printf("no check :(");
+    exit(1);
+}
 // Just check the newest 10 messages.
-for($i = 0; $i < 10; $i++) {
+for($i = 0; $i < 30; $i++) {
     // TODO: Process these in order?
     $header = imap_header($imap, $number - $i);
-    if (strpos($header->to[0]->mailbox, "+songs")){
+    if (isset($header->to[0]) && strpos($header->to[0]->mailbox, "+songs")){
         $json = json_decode($header->subject);
         $song = Song::findOrFail($json->id);
         $body = quoted_printable_decode(imap_body($imap, $number - $i));
@@ -25,7 +33,6 @@ for($i = 0; $i < 10; $i++) {
         $song->save();
         imap_delete($imap, $number - $i);
         printf("updated song {$song->id}");
-        exit(0);
     }
 }
 exit(0);
diff --git a/laravel/public/playlist.gmi b/laravel/public/playlist.gmi
index d384b6d..95d5c30 100755
--- a/laravel/public/playlist.gmi
+++ b/laravel/public/playlist.gmi
@@ -18,10 +18,11 @@ if($playlist){
             return;
         }
         $playlist->songs()->toggle([$song->id]);
+        printf("30 " . $playlist->name . "\r\n");return;
     }
     printf("20 text/gemini\r\n");
 } else {
-printf("30 " . Playlist::inRandomOrder()->first()->name . "\r\n");return;
+    printf("30 " . Playlist::inRandomOrder()->first()->name . "\r\n");return;
 }
 $songs = $playlist->songs()->pluck('title','songs.id');
 ?>
diff --git a/laravel/public/song.gmi.php b/laravel/public/song.gmi.php
index edf9b2a..7da3606 100755
--- a/laravel/public/song.gmi.php
+++ b/laravel/public/song.gmi.php
@@ -25,6 +25,8 @@ printf("30 " . Song::inRandomOrder()->first()->id . "\r\n");return;
 
 => <?= $song->id ?>?q Transpose from <?= $song->plain_key ?>
 
+<?= $song->audio ? "=> {$song->audio} Listen to this song" : "" ?>
+
 ```chord sheet
 <?= $txt = $song->textTranspose(getenv('QUERY_STRING')??'') ?>