Your 3rd Add-On: Online Audio!
#1
Discussion topic for the Online Audio Add-on wiki tutorial

http://kodi.wiki/view/HOW-TO:Audio_addon

Image

Special thanks to curti for writing the original source.

https://github.com/zag2me/plugin.audio.example

This wiki guide is up but could use fleshing out if someone wants to jump in?

As always, feel free to discuss in this thread and post any modifications you make to the code.
Reply
#2
Well I already used the video tutorial by Roman_V_M for my audio plugin.
Worked out well, even with some starting issues.

I have a question though. Can I access the fanart in the plugin folder somehow?
I want to set the default plugin fanart as the fanart for my listitems when the user chose a song to listen to.

I tried to google it, but my google skills seems to be shit, and the plugin dev page doesn't seem to cover it.


EDIT:
nevermind, turned out that i'm too stupid to use google properly.
Reply
#3
(2016-01-20, 15:46)blackanthrax Wrote: EDIT:
nevermind, turned out that i'm too stupid to use google properly.

Please post your code solution here so everyone can benefit.
Reply
#4
Hi, and thanks for this channel for kodi future "coders".

I downloaded the zip file from git and tried to install it from GUI xbmc (already available in debian) / kodi (ver 14) but I get a message:

Dependencies are not met - Please contact add on author.

I use debian jessie

I read on other threads, maybe decompress the zip file under ~/.kodi/addons Huh? or what dependences are not met?

Thanks in advance for your help.
Reply
#5
Hi, Great Plugin tutorial.

Looking for a bit of help.

I run a Web based Radio station.

I have the Plugin to play a live stream from my station and added this to the plugin so I can display my listen again page.

I have the plugin scrape my site for mp3's in my upload folder which it is showing fine from a Wordpress Blog but its actually displaying the filenames. Is it possible for it to display them as the Post name from the Posts page ?

Image

Thanks for any help to get this up and running.

Kevin
Reply
#6
(2016-01-31, 02:00)francis Wrote: Hi, and thanks for this channel for kodi future "coders".

I downloaded the zip file from git and tried to install it from GUI xbmc (already available in debian) / kodi (ver 14) but I get a message:

Dependencies are not met - Please contact add on author.

I use debian jessie

I read on other threads, maybe decompress the zip file under ~/.kodi/addons Huh? or what dependences are not met?

Thanks in advance for your help.

Fixed. I directly unziped the script under ~/.kodi/addons.

Installed on debian beatiful soup with: apt-get install python-bs4

Working and redy to analize and enrich.

Thanks for the addon and the explanation in the wiki. Good contribution for kodi addon starters.
Reply
#7
Hi I'm new on addons development and I need some help.
My project is on github [here the link] All it does is getting links from a web site that offer some trials audio file. All is ok when I get the first page, but when I try to create a next button that link two the second page it fail. The file is default.py.
Can someone help me please?
Reply
#8
Hi, thanks for your sample code.

I've tried to grab some music from another site. Please help me for how to build_url.

In the source of function: build_song_list
# build the plugin url for Kodi
# Example: plugin://plugin.audio.example/?url=http%3A%2F%2Fwww.theaudiodb.com%2Ftestfiles%2F01-pablo_perez-your_ad_here.mp3&mode=stream&title=01-pablo_perez-your_ad_here.mp3

My URL is something like this: http://chiasenhac.vn/nhac-hot/something-...e2vek.html
But underlying stream for this song is something like this:
<audio id="jp_audio_0" preload="metadata" src="http://data.chiasenhac.com/stream/1768/5/1767877-78ef562d/320/Something%20Just%20Like%20This%20-%20The%20Chainsmok.mp3.csn" title="Something Just Like This"></audio>

Almost streaming audio/video are using some mechanism to change/hide actual songs. How can I grab the plugin link to pass to Kodi?

url = build_url({'mode': 'stream', 'url': songs[song]['url'], 'title': songs[song]['title']})
Reply
#9
Sad 
Hi. I'm new to the forum.
I have a problem with my addon. It's based on the online audio example addon. It should play audio from my local webserver. When I try to start it, an errormessage pops up. Can someone help me?
Jan

Kodi log: https://paste.kodi.tv/ofuzahefol
Screenshot of the errormessage (German): https://drive.google.com/open?id=1rJvk04...Pfp6DkktRf
Reply
#10
(2018-10-03, 19:26)J.Kakaofanatiker Wrote: Hi. I'm new to the forum.
I have a problem with my addon. It's based on the online audio example addon. It should play audio from my local webserver. When I try to start it, an errormessage pops up. Can someone help me?
Jan

Kodi log: https://paste.kodi.tv/ofuzahefol
Screenshot of the errormessage (German): https://drive.google.com/open?id=1rJvk04...Pfp6DkktRf
 The error in your log is pretty self explanatory I would have thought.  Probably you have album_cover defined outside of a function that you are trying to use it in and haven't passed album_cover into the function.  Python variables are local unless you specify otherwise.
Learning Linux the hard way !!
Reply
#11
Bug 
Hello,
I fixed the problem. But now it's unable to play the audio. It shows ervery file two times but when I want to play one, an errormessage pops up.
Jan
Kodi log: https://paste.kodi.tv/ecevodijim
Reply
#12
So I have been trying to create the most basic of audio addons pretty much for two days and am pulling my hair out.

Basically I've created the basic addon to pull podcast episodes from view-source:https://thisiscriminal.com/episodes/ and I can see the .mp3 links, episode icon and title there, but after looking through addon after addon, pretty much every single guide online, nothing is working. Every guide says pull the data from the <div> section. That site doesn't use those sections or markers like most other sites do.

I'm at the point where I will seriously pay someone to do this as I'm just editing code now making wild stabs in the dark.

I've also been using this editor/checker, Audrey-tester but since putting my .json file into an online checker it's full of errors even though I've followed the instructions exactly from the website. .json file here. Any tips would be greatly appreciated please!
Reply
#13
(2019-06-06, 07:02)leopheard Wrote: Any tips would be greatly appreciated please!

Here's a tip: do not mention or link anything from a TVAddons perspective. It is totally off-limits on this forum, as it is too many ties to video piracy as per our forum rules (wiki).
Got a Kodi problem? Provide a full Debug log (wiki) | Usefull pages: First time user (wiki) | Troubleshooting (wiki) | Free content (wiki) | Forum rules (wiki) | VPN policy (wiki)
Reply
#14
Hi all,

So I've taken this working addon (just checked) and am trying to get it to pull various field from the following website: thisiscriminal.com to make a podcast addon.

This seems to be the simplest addon I can find for audio and as I expected, I'm not skilled enough to get it to work.

The kodi log is showing the following errors: Paste log

The code I'm using is as follows - any thoughts please?

import os
import sys
import urllib
import urlparse
import xbmcaddon
import xbmcgui
import xbmcplugin
# http://docs.python-requests.org/en/latest/
import requests
# http://www.crummy.com/software/BeautifulSoup/bs4/doc/
from bs4 import BeautifulSoup

def build_url(query):
    base_url = sys.argv[0]
    return base_url + '?' + urllib.urlencode(query)
    
def get_page(url):
    # download the source HTML for the page using requests
    # and parse the page using BeautifulSoup
    return BeautifulSoup(requests.get(url).text, 'html.parser')
    
def parse_page(page):
    songs = {}
    index = 1
    # the sample below is specific for the page we are scraping
    # you will need to view the source of the page(s) you are
    # planning to scrape to find the content you want to display
    # this will return all the <a> elements on the page:
    # <a href="some_url">some_text</a>
    for item in page.find_all('image'):
        # the item contains a link to an album cover
        if item['href'].find('.jpg') > 1:
            # format the url for the album cover to include the site url and url encode any spaces
            album_cover = '{0}{1}'.format(sample_page, item['href'].replace(' ', '%20'))
        # the item contains a link to a song containing '.mp3'
        if item['href'].find('.mp3') > 1:
            # update dictionary with the album cover url, song filename, and song url
            songs.update({index: {'album_cover': album_cover, 'title': item['href'], 'url': '{0}{1}'.format(sample_page, item['href'])}})
            index += 1
    return songs
    
def build_song_list(songs):
    song_list = []
    # iterate over the contents of the dictionary songs to build the list
    for song in songs:
        # create a list item using the song filename for the label
        li = xbmcgui.ListItem(label=songs[song]['title'], thumbnailImage=songs[song]['album_cover'])
        # set the fanart to the albumc cover
        li.setProperty('fanart_image', songs[song]['album_cover'])
        # set the list item to playable
        li.setProperty('IsPlayable', 'true')
        # build the plugin url for Kodi
        # Example: plugin://plugin.audio.example/?url=http%3A%2F%2Fwww.theaudiodb.com%2Ftestfiles%2F01-pablo_perez-your_ad_here.mp3&mode=stream&title=01-pablo_perez-your_ad_here.mp3
        url = build_url({'mode': 'stream', 'url': songs[song]['url'], 'title': songs[song]['title']})
        # add the current list item to a list
        song_list.append((url, li, False))
    # add list to Kodi per Martijn
    # http://forum.kodi.tv/showthread.php?tid=...pid2094170
    xbmcplugin.addDirectoryItems(addon_handle, song_list, len(song_list))
    # set the content of the directory
    xbmcplugin.setContent(addon_handle, 'songs')
    xbmcplugin.endOfDirectory(addon_handle)
    
def play_song(url):
    # set the path of the song to a list item
    play_item = xbmcgui.ListItem(path=url)
    # the list item is ready to be played by Kodi
    xbmcplugin.setResolvedUrl(addon_handle, True, listitem=play_item)
    
def main():
    args = urlparse.parse_qs(sys.argv[2][1:])
    mode = args.get('mode', None)
    
    # initial launch of add-on
    if mode is None:
        # get the HTML for http://www.theaudiodb.com/testfiles/
        page = get_page(sample_page)
        # get the content needed from the page
        content = parse_page(page)
        # display the list of songs in Kodi
        build_song_list(content)
    # a song from the list has been selected
    elif mode[0] == 'stream':
        # pass the url of the song to play_song
        play_song(args['url'][0])
    
if __name__ == '__main__':
    sample_page = 'https://thisiscriminal.com/wp-json/criminal/v1/episodes?posts=1000000&page=1'
    addon_handle = int(sys.argv[1])
    main()
[/quote]
Reply
#15
As of 2021, this add-on example no longer works. The page at http://www.theaudiodb.com/testfiles/ returns 404. The tutorial is still useful for learning, but it would be helpful if it were updated to scrape a new site.
Reply



Logout Mark Read Team Forum Stats Members Help
Your 3rd Add-On: Online Audio!0
This forum uses Lukasz Tkacz MyBB addons.