RadioDJ - Free Radio Automation Software Forum

Now playing plugin coding help

Offline RFU

  • ****
  • 447
    • Radio Free Ukraine
Now playing plugin coding help
« on: March 23, 2019, 04:47:17 PM »

Frank
(17:33:05) I want to make a change to the now playing plugin and I hope someone can help me with the coding

The part that needs changing is in display.php

Code: [Select]
<div class="now-playing clearfix">

        <figure class="album-art">
        <?php if( !empty($data['cover'])  : ?>
            <img src="<?php echo $data['cover']; ?>" width="250" title="<?php echo $data['album']; ?>" />
            <!--<figcaption><?php echo $data['album']; ?></figcaption> -->
        <?php endif; ?>
        </figure>

<div class="artist"><small>Artist: </small><?php echo $data['artist']; ?></div>

<div class="title"><small>Title: </small><?php echo $data['title']; ?></div>

<?php if( !empty($data['album']) : ?>
<div class="album"><small>Album: </small><?php echo $data['album']; ?></div>
<?php endif; ?>

<?php if( !empty($data['year']) : ?>
<div class="year"><small>Year: </small><?php echo $data['year']; ?></div>
<?php endif; ?>

</div>

I have been adding hashtags to the artist names (i.e. Johns Band #johnsband) but in many instances there are two or even three hashtags because the artist was not consistent throughout the various social media platforms.

So sometimes It ends up looking like  Johns Band #johnsband #johns_band ##johns_band_official, etc and it looks like crap

If someone could tell me the coding, what I would like to have happen is to add a line break so that
Johns Band #johnsband #johns_band ##johns_band_official

ends up looking like

Johns Band
#johnsband #johns_band ##johns_band_official

With all the hashtags on a second line under the name of the artist.

Can someone tell me what the coding should be so the php file recognizes that if there is a # it should line break before the hashtag?
Гордий бути українцем, Ми - Радіо Вільної України.

Re: Now playing plugin coding help
« Reply #1 on: March 23, 2019, 06:37:33 PM »
first please explain where the hashtags come from.
is it in the database as a separate data field in the Songs table, or are you just taking the artist name, and copying it ans inserting a hash symbol in front of it?

Code: [Select]

<?php
if (strpos("".$data['artist'], "#") !== false )
{
   echo 
"a hash symbol was found, adding line break";
   echo 
"< br />";
   echo 
" i just added a line break<br />" ;
}
?>


Offline RFU

  • ****
  • 447
    • Radio Free Ukraine
Re: Now playing plugin coding help
« Reply #2 on: March 23, 2019, 07:24:08 PM »
I'm adding the hashtags after the artist name. And I'm searching twitter and instagram to find them
Гордий бути українцем, Ми - Радіо Вільної України.

Re: Now playing plugin coding help
« Reply #3 on: March 24, 2019, 01:45:03 AM »
but what are you doing with those hashtags after you find them? are you putting them in the metadata of the song table in the database?

Offline RFU

  • ****
  • 447
    • Radio Free Ukraine
Re: Now playing plugin coding help
« Reply #4 on: March 24, 2019, 05:09:00 AM »
I suggest you read my first post

The hashtags are being added to the artist name in each individual song file the database

And that code you gave me didnt' work
« Last Edit: March 24, 2019, 05:15:24 PM by RFU »
Гордий бути українцем, Ми - Радіо Вільної України.

Re: Now playing plugin coding help
« Reply #5 on: March 25, 2019, 03:23:31 PM »
I did read your first post, but what was not clear to me at that time, but maybe now I understand, you are editing the artist's name, and putting hashtags in the Artist data field, along with the artist name. So in both RadioDJ and the database, it is showing "Johns Band #johnsband #johns_band ##johns_band_official"

In my opinion, that is bad to edit the artist data field like that.

I recommend you create a new data field (column) in the database table "songs" and name it "artist_twitter_accounts", and put all the hashtags into that data field. Then it is real easy to control how it is displayed in the php script, including making a hyperlink from the hashtags, so they link to the artist's twitter page.

but if you want to keep it the way you have done it so far, that php code will detect if there is a hash symbol in the artist name.

but if you want me to do all the work...

Code: [Select]
<?php

$artist_data 
"Billy Idol #BillyIdol" ;

?>



<div class="artist"><small>Artist: </small>
<?php  
// test if there is a hash symbol in the artist data field
if (strpos("".$artist_data"#") !== false )
{
// yes hash symbol found...
echo "hash found";
//  print the artist's data up to the hastag symbol
$artist_name substr($artist_data0strpos("".$artist_data"#") );
echo $artist_name
// next print a line break
echo "<br />";
// next print the rest of the artist data, which will be hashtags
$artist_twitter_names substr($artist_datastrpos("".$artist_data"#")  );
echo $artist_twitter_names;
}
else
{
// no hash tag, just print the artist data
echo $artist_data;
}
?>

</div>



http://tpcg.io/PAx4sz



Offline RFU

  • ****
  • 447
    • Radio Free Ukraine
Re: Now playing plugin coding help
« Reply #6 on: March 26, 2019, 08:52:25 AM »
Believe me, I thought of that. I was going to use another field in the mp3 tag that RadioDJ imports. The problem is, the hashtags are not only for the "now playing" on our website.

Twitter, Instagram and Facebook only post the artist name, song name, and album art. So to put the hashtags in another field would not work on social media

This is the only workable solution to get it to appear as

"Johns Band #johnsband #johns_band ##johns_band_official JOHN'S SONG" on social media. It has to be in the artists name field

And so far, my social media interaction and listeners has more than doubled since I started adding hashtags, including the artists themselves reposting my station content
Гордий бути українцем, Ми - Радіо Вільної України.

Re: Now playing plugin coding help
« Reply #7 on: March 26, 2019, 04:26:27 PM »
how is the song metadata being posted to Twitter, Instagram and Facebook?

Chances are you are using a script of some sort, and that script could retrieve data from the database, and manipulate it in any way you wanted to have the output be.

And the Twitter API has an entities object mention function where you can add all user hashtags to appear in the tweet.
https://developer.twitter.com/en/docs/tweets/data-dictionary/overview/entities-object.html#mentions

of course these hashtags help. very artist wants to promote themselves.

Offline RFU

  • ****
  • 447
    • Radio Free Ukraine
Re: Now playing plugin coding help
« Reply #8 on: March 27, 2019, 11:38:32 AM »
Does anyone else know php coding and can do the simple code change I need?
Гордий бути українцем, Ми - Радіо Вільної України.

Re: Now playing plugin coding help
« Reply #9 on: March 27, 2019, 02:18:15 PM »
i just did it all for you!  :D

Offline RFU

  • ****
  • 447
    • Radio Free Ukraine
Re: Now playing plugin coding help
« Reply #10 on: March 27, 2019, 02:44:11 PM »
No. You didn't

All you did was tell me I was wrong, and to do it YOUR way, which does not solve my problem

And, NO, I'm not adding fields to the database

I'll pay some 12 year old to do it properly
Гордий бути українцем, Ми - Радіо Вільної України.