Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
George RR Fartin
Apr 16, 2003




Humble Request

A program to cross reference a list of days/times and to download files from a site that uses a specific naming format for days/times, as well as to rename the first four letters to a set of characters defined in the initial list.

Problem:

WZBC, a college station near me, archives their shows using the following format:

http://zbconline.com/wzbc-2019-MM-DD-HH-00.mp3

I've been manually downloading and renaming the shows I like to listen to (oftentimes the timing doesn't really line up with, say, me being at work, etc), and while this is fine, it's relatively time consuming.

Description and requirements:

So the idea is this: a program that looks to a text file for five pieces of data: Day of Week, Start Time, End Time, Lookback and Name, for as many entries as are present. The Day of the week should be converted to the actual date format (MM-DD), and the program should look back Lookback number of days, downloading the file and formatting it after the fact by adding the Name where "wzbc" normally exists. The Start/End times would tell the program how many files to rename using the Name.

So this might play out with a text file that looks like this, with a pipe delimiter:

M|8|10|IR

or

MON|0800|1000|IR (since this wouldn't require you to format the times)

...which for this week, would pull

http://zbconline.com/wzbc-2019-04-29-08-00.mp3
http://zbconline.com/wzbc-2019-04-29-09-00.mp3

and rename the files:

IR-2019-04-29-08-00.mp3
IR-2019-04-29-09-00.mp3

...once they have downloaded.

Nice to have features:

I'm really flexible on how this works out. I've tried to explain it in what seems to be the easiest method of accomplishing the goal, though I'm sure there are prettier ways to do it. If you can figure out a way to cross reference the schedule for the station (found at https://spinitron.com/WZBC/calendar), that's great, but I feel like that makes this a much larger endeavor. I don't need anything fancy; I just take the files and shove them into folders for their respective shows, and this would save me 15-20 minutes a week of relatively monotonous work. I'd prefer that it run in Windows, but I have a Mac laptop hanging around too, in case you have a preference.

Thanks in advance (even if you're just reading this).

Adbot
ADBOT LOVES YOU

George RR Fartin
Apr 16, 2003




Chunjee posted:

I poked around on their site and didn't see an RSS feed. What gives. That would have negated the need for this as any podcast tool would fit perfectly. Ah well.

From the way you've described this theoretical program, their site knows how to give you that block of airtime and it's not a prexisting mp3 file sitting in a folder?

I'm fairly certain it's the latter case, as each file has a two-three minute buffer from the last time period (so the 1pm file will pick up at 12:58, even though the 12pm file already has that). Couldn't say for certain, though - I'm honestly not sure how any of that backend stuff works.

(Frankly, I'm at the level where I was quite pleased with myself for determining the way they store the shows in the first place. Some shows were offering "mixtapes" for a week or so, which were just that week's airing, but it's not everything, and sometimes it's just nice to be able to listen to That Weird Ambient Noise Show That's On For Three Hours, but Starts at 11pm during the workday.)

Also, re: the lack of RSS feed: it's a college station, and the actual schedule itself is new as of a year or so ago. It used to just be a page they'd manually update. I think they just kinda lack resources for keeping this poo poo up (and as a person who went to a State school and worked for the paper, I totally get it - if I were to guess, they have the one CS major who also likes radio doing most of the grunt work).

George RR Fartin fucked around with this message at 18:24 on Apr 29, 2019

George RR Fartin
Apr 16, 2003




Yeah, the more I think of it, the more kinda difficult this all becomes. I think it's just hard for me to wrap my head around where certain more abstracted things would come from - like: if I say MONDAY is the day I care about, I can check a calendar for the last X mondays within a range, which also requires me to be aware of where we are in the month so I can pop back a month (or more) if need be. So that's a whole thing, just to find the month and date. The rest is somewhat easier in terms of formatting the link, since we'd just sort of do a while loop from the start time to the end time, but that date is the real sticky bit.

My idea of an individual text file is purely out of my own familiarity with how that sort of thing works. That is: you read the text file until a specific delimiter, save that as variable DAY, read until the next delimiter, save that as START, next END, next NAME, then have a predetermined end-of-line character just to populate everything so the above algorithm can be applied. Once the downloading and renaming is done, check to see if there's another line and do it all over again if there is. I'm sure there's probably an easier way (even like, simple input might not be bad: just ask for each value, process everything, and return to asking each value once the process is done downloading). It's absolutely not set in stone.

I feel like I'm asking for a sort of big pain in the butt here, so if that's at all the case, please don't worry yourself too much with it.

I'm also totally open for this batch file idea if that's just far less of a pain. I can just edit in date/time ranges if that makes more sense (and since only the former is likely to change all that often, it wouldn't even be that time intensive).

George RR Fartin
Apr 16, 2003




Flipperwaldt posted:

I just want to inform anyone working on this that you can easily scrape the list of files that are actually available from http://zbconline.com/. You just have to change the file extension from m3u to mp3. Looks like the archive only ever goes back two weeks (ie. stuff not listed on the page apparently isn't available anymore).

Figured if I could get that and scrape the calendar data, it'd be easy enough to match it all up and offer a simple list with checkboxes and a download button, which would offer a reasonable alternative workflow. But the calendar data is offered in a way that I don't know how to scrape.

poo poo, I forgot about the two week window - I've been doing this manually weekly, but I remember being curious and trying further back and getting nothing. So you could just hardcode how far back to go, and not redownload any duplicates.

Thanks for looking into this, everyone. I realize it's sort of the equivalent of just showing up at a stranger's house and asking them to make you a pie. :)

George RR Fartin
Apr 16, 2003




TheLastManStanding posted:

Let me know if it works :ohdear:

It works!

The first time I ran it, I got a popup that kinda sat around doing nothing. Upon closing this, I got the progress bar, but it didn't fit the window. It downloaded all instances of Infernal Racket (the only show I put in for testing), renaming the files and sticking them in the named folder appropriately.

So I added another show, and ran the file again. This time, only the one popup appeared, and it worked swimmingly.

I'm not sure what would account for the issue in the initial run, but it could be related to my work PC being older than dirt and using Win7. Even with the minor initial UI issue, everything else works perfectly.

Thanks for putting this together!


EDIT: I have a total of 15 shows on the list, ran the program, and it did everything it needed to do. No weird UI stuff, either, so that had to have just been a fluke. Figured I'd update with that so you knew it could do a good deal of work if it has to without running into issues.

George RR Fartin fucked around with this message at 15:56 on May 2, 2019

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply