Here's the situation - tell me if this isn't something I can do.

I have a large account with plenty of storage at a shared hosting provider. They don't want me running streamripper, however. So I have a VPS that I'm using to do the ripping. I have that configured and its ripping away merrily and I even have the XML-RPC link set up to grab the schedule from the hosting server. How is it that I can import the ripped files from the VPS onto the shared account where the main hosting is - or is that possible?

(using beta4)

Comments

drewish’s picture

Humm... I seem to remember someone (WSUM?) had a script that uploaded the mp3s via FTP to another server. Take a look in the radio group on g.d.o and see if you see anything.

refreshingapathy’s picture

That's what I was starting to work on (scp, actually), but I wanted to make sure this wasn't something hidden away in the depths of the functionality of the module already.

refreshingapathy’s picture

First run at it:


#!/bin/bash

for a in $(ls /DRUPAL-RIP-ROOT/sites/all/modules/station/archive/import|grep mp3);
        do
                scp -i ~/.ssh/PRIVATEKEY $a USER@HOST:/DRUPAL-WEB-ROOT/sites/all/modules/station/archive/import/$a
                rm $a
        done

Todo later today is make it filter by size so we don't snag the file that stream ripper is still working on.

refreshingapathy’s picture

Second run after I realized find is way more efficient here:

#!/bin/bash

for a in $(find /DRUPAL-RIP-ROOT/sites/all/modules/station/archive/import -size +50M -name '*.mp3' -ls);
        do
                scp -i ~/.ssh/PRIVATEKEY $a USER@HOST:/DRUPAL-WEB-ROOT/sites/all/modules/station/archive/import/$a
                rm $a
        done

Figuring that an hour of audio is somewhere around 60-ish MB for me... I'm planning to run this at quarter past the hour, so the current file won't be much larger than 15 or 20MB.

drewish’s picture

Oh, so had some time and found the thread on g.d.o: http://groups.drupal.org/node/8475

One thing to take from that is that you should use the existence of a .cue file as a signal that the rip is still in progress.

refreshingapathy’s picture

Thanks drewish - the size comparison with find was giving all sorts of problems trying to get it to pass things to scp. My sed/awk is weak, I admit it. I'll put in something about searching for a same-name cue file and throw it here when I figure it out.

drewish’s picture

Why bother doing it in the shell? Just fork the ripper.php and add some exec() calls to do the scp-ing from there...

drewish’s picture

Perhaps we could make it more general and add two options to the ini for pre and post rip commands to run? That would be the Drupal way...

refreshingapathy’s picture

RE #7 - I needed a quick and dirty way to stick things together for the next few days, and the quick and dirty way for me is shell scripting (more comfortable for me than PHP for a kludge solution).

RE #8 - yeah that'd be pretty badass. I'll take a crack at it this week.

Also, final shell script:


#!/bin/bash

for a in $(ls /DRUPALROOT/sites/default/modules/station/archive/import | grep mp3 | sed 's/\(.*\)\..*/\1/');
        do
                if [ -a /DRUPALROOT/sites/default/modules/station/archive/import/$a.cue ]; then
                        echo "not ready yet..."
                else
                        scp -i ~/.ssh/PRIVATEKEY $a.mp3 USER@REMOTEHOST:REMOTEDRUPALROOT/sites/default/modules/station/archive/import/$a.mp3
                        rm $a.mp3
                fi
        done
refreshingapathy’s picture

Assigned: Unassigned » refreshingapathy
Category: support » feature
refreshingapathy’s picture

Status: Active » Needs review
StatusFileSize
new308 bytes
new681 bytes

Finally got around to doing this tonight. Just a quick exec and the addition of two more lines for the inc file. Patches attached for both the ripper.php and ripper.inc file.

refreshingapathy’s picture

StatusFileSize
new792 bytes
new1.29 KB

Posted wrong diffs - those are quite ugly. diff -up attached.

drewish’s picture

Status: Needs review » Needs work

The idea is right but it needs a little clean up.

Please remove your site specific changes from the .ini file:

@@ -2,13 +2,13 @@
 ; These are the settings for the stream ripper script.
 
 ; Complete URL of webstream to rip
-stream_url = "http://127.0.0.1:8000/high"
+stream_url = "http://peace.str3am.com:6440"
 
 ; Full path to the stream ripper executable, version 1.61.17 or higher.
-streamripper_path = "/usr/local/bin/streamripper"
+streamripper_path = "/opt/local/bin/streamripper"
 
 ; Full path to station archive module's import directory (no trailing slash)
-import_path = "/usr/local/www/drupal/sites/all/modules/station/archive/import"
+import_path = "/Users/RickHeil/Desktop"
 
 ; Because shows tend to start early or finish late, the overlap_seconds
 ; setting allows you to determine how much the recording should overlap at the

I'd add a bit more to the pre/post-rip command comments mentioning that multiple commands can be separated by semi-colons:

@@ -19,3 +19,11 @@ overlap_seconds = 60
 
 ; The file type of the stream; "mp3" and "ogg" are supported.
 file_format = "mp3"
+
+; Pre-rip command - command(s) to be executed before the ripping starts. This is meant
+; for shell commands, this won't parse PHP.
+prerip_command = ""
+
+; Post-rip command - command(s) to be executed at the end of the ripping script. This is meant
+; for shell commands, this won't parse PHP.
+postrip_command = ""

I'd change the pre-post command to only execute if there's a setting:

if (!empty($settings['prerip_command'])) {
  exec($settings['prerip_command']);
}

Also it's not required but if you checkout the source from CVS you can use it to generate a single patch file.

refreshingapathy’s picture

Thanks drewish. Forgot to take some of my config out from the quick test I ran through on the dev. I'll brush it up again later tonight.

refreshingapathy’s picture

Status: Needs work » Needs review
StatusFileSize
new1.92 KB

Improved patch, made correctly, with the correct naming scheme. Starting to get the hang of this - sorry for the roughness, I've never contributed code before.

drewish’s picture

Looking a lot better only two small things at this point:
- There's a tab used to indent the exec() lines. Drupal's coding standards call for using two spaces to indent.
- I think you could simplify the test before calling exec() as i outlined in comment#13.

drewish’s picture

Oh, wanted to add that we're excited to have you contributing. It's all about starting small, my first patch changed a single line: #34031: Delete button on the edit user account form should be after the submit button

refreshingapathy’s picture

StatusFileSize
new1.92 KB

Coding styles fixed, I need to go over those again as well.

I'm not sure what you mean by simplifying the check. I think checking the .inc files is probably the most direct method, no?

drewish’s picture

The thing is that you're adding in another variable $postrip_command that really doesn't do much besides duplicate the value of $settings['postrip_command']. You can check existence and exec($settings['postrip_command']) directly rather than adding a second variable. Also "{$postrip_command}" is actually a bit wasteful. You're doing string replacement to extract the value of the variable. You could just use $postrip_command without bothering with the quotes.

drewish’s picture

Version: 6.x-2.0-beta4 » 6.x-2.x-dev
StatusFileSize
new1.95 KB

This is what I'd meant.

drewish’s picture

Status: Needs review » Fixed

Committed to HEAD (with some changes to the line wrapping on the comments).

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.