Author Topic: Automatic adding Internet Radio streams to LinuxMCE  (Read 51709 times)

Dap-P

  • Veteran
  • ***
  • Posts: 106
    • View Profile
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #15 on: October 28, 2013, 08:37:21 pm »
Had some sparetime, and name some progress on the script,

New features:
- Use variable for tempfile
- Check if the Url is already in the DB before adding
- Reuse genre if it exists
- Adds genre if it not exists
- Uses SELECT MAX(id) to find out last added row

@sambuca, i couldn't get a working SELECT LAST_INSERT_ID, i think if it because i used 2 seperate mysql -e statements, If MAX(id) is not suitable, i have to make LAST_INSERT_ID working somehow

Attached is the new version

Anton
« Last Edit: January 12, 2014, 02:56:52 pm by Dap-P »

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #16 on: October 28, 2013, 09:09:25 pm »
use it in the same connection, as I outlined in a previous post:

mysql pluto_media -e "INSERT INTO File (Filename) Values ('abcd'); SELECT LAST_INSERT();"

As you see, you have two statements, on a single connection. That way, you get the last inserted ID.
« Last Edit: October 28, 2013, 09:11:15 pm by posde »

Dap-P

  • Veteran
  • ***
  • Posts: 106
    • View Profile
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #17 on: October 28, 2013, 09:38:44 pm »
I thought it would work that way, when i realised it didn't work as plan. thanks!!!

Here 2 new scripts,
 - add radiostations with select_last_id
and
 - delete radiostations

Anton
« Last Edit: January 12, 2014, 02:57:07 pm by Dap-P »

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #18 on: October 28, 2013, 09:43:25 pm »
The first file doesn't look right in line 25

Dap-P

  • Veteran
  • ***
  • Posts: 106
    • View Profile
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #19 on: October 28, 2013, 09:48:58 pm »
What does not look right?
to me it seems correct, i do the insert, and last_insert in 1 command, with the output in $PK_File var

it even works for me

Anton

WhateverFits

  • Guru
  • ****
  • Posts: 230
    • View Profile
    • Sean Walker
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #20 on: October 29, 2013, 04:50:11 am »
What does not look right?
to me it seems correct, i do the insert, and last_insert in 1 command, with the output in $PK_File var

it even works for me

Anton

The lines are tuncated:

Code: [Select]
               PK_File=$(mysql pluto_media -e "insert into File (EK_MediaType,DateAdded,Filename,Missing,IsDirectory,IsNew) VALUES(43,NOW(),'$Url',0,0,1);$

                #Add Station Name to Database
                FK_Attribute=$(mysql pluto_media -e "insert into Attribute (FK_AttributeType,Name) VALUES(10,'$Station');select LAST_INSERT_ID() from Attri$

Dap-P

  • Veteran
  • ***
  • Posts: 106
    • View Profile
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #21 on: October 29, 2013, 11:36:07 pm »
My mistake...

Here are the correct ones:

« Last Edit: January 12, 2014, 02:57:19 pm by Dap-P »

WhateverFits

  • Guru
  • ****
  • Posts: 230
    • View Profile
    • Sean Walker
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #22 on: October 29, 2013, 11:46:50 pm »
Thanks! Looks good, now I can test it.

Marie.O

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 3676
  • Wastes Life On LinuxMCE Since 2007
    • View Profile
    • My Home
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #23 on: October 30, 2013, 03:30:40 pm »
Looks much better. One more little thing. To get rid of the tail -1 you have, use

mysql pluto_media -ss -e "SELECT 123"

That way, it will only return the resultset without any fieldname etc. The two 's' are the reason for mysql to be (s)ilent.

Dap-P

  • Veteran
  • ***
  • Posts: 106
    • View Profile
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #24 on: October 30, 2013, 11:31:58 pm »
New update

Added a description to the script,
added the -ss flag, and removed tail -n1
added the Download Url to a variable
in the delete script added a loop, so that it reads all urls, and checks that in the database


In general, would it be wise to add multiple files to the same radiostation? Now i just grab the first one.

Anton
« Last Edit: January 12, 2014, 02:57:30 pm by Dap-P »

WhateverFits

  • Guru
  • ****
  • Posts: 230
    • View Profile
    • Sean Walker
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #25 on: October 31, 2013, 07:32:50 pm »
In general, would it be wise to add multiple files to the same radiostation? Now i just grab the first one.

So far, this looks rather good. I've tested the prior version and now I'm going to test this one. It works great! I did have a duplicate URL attempted to get inserted and it failed gracefully. Very nice. Now, can you give an example of multiple files and the same radiostation? Example XML would be good to know what you are talking about.

Thanks for the good work!

Dap-P

  • Veteran
  • ***
  • Posts: 106
    • View Profile
Re: Need help with automatic adding Internet Radio streams to LinuxMCE
« Reply #26 on: November 01, 2013, 10:24:13 pm »
New update :

Now it is only 1 script

Added a show function, this will display all local radio stations, with their Url's and Genre

Anton

Edit: Somehow i broke the script... i will check it now
Edit 2: I think it is working again
I had to readd the tail -n1 for some commands, apparently the insert_last_id somehow returned multiple lines
« Last Edit: January 12, 2014, 02:57:42 pm by Dap-P »

Dap-P

  • Veteran
  • ***
  • Posts: 106
    • View Profile
Re: Automatic adding Internet Radio streams to LinuxMCE
« Reply #27 on: November 16, 2013, 08:24:03 pm »
Who has tested this, and what were the results?

Also, is it more clear, what i mean with multiple Urls for the same radiostation?


Anton

ardirtbiker

  • Guru
  • ****
  • Posts: 308
    • View Profile
Re:
« Reply #28 on: November 16, 2013, 11:50:26 pm »
It worked for me.. no problems

Sent from my SCH-I535 using Tapatalk 4

ladekribs

  • Veteran
  • ***
  • Posts: 86
    • View Profile
Re: Automatic adding Internet Radio streams to LinuxMCE
« Reply #29 on: November 18, 2013, 08:17:09 am »
It worked for me also, no problems either. Nice!

BR Stefan