<!DOCTYPE html> <!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]--> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>royalnet.audio — Royalnet documentation</title> <script type="text/javascript" src="_static/js/modernizr.min.js"></script> <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script> <script type="text/javascript" src="_static/jquery.js"></script> <script type="text/javascript" src="_static/underscore.js"></script> <script type="text/javascript" src="_static/doctools.js"></script> <script type="text/javascript" src="_static/language_data.js"></script> <script type="text/javascript" src="_static/js/theme.js"></script> <link rel="stylesheet" href="_static/css/theme.css" type="text/css" /> <link rel="stylesheet" href="_static/pygments.css" type="text/css" /> <link rel="index" title="Index" href="genindex.html" /> <link rel="search" title="Search" href="search.html" /> <link rel="next" title="royalnet.bots" href="bots.html" /> <link rel="prev" title="royalnet" href="index.html" /> </head> <body class="wy-body-for-nav"> <div class="wy-grid-for-nav"> <nav data-toggle="wy-nav-shift" class="wy-nav-side"> <div class="wy-side-scroll"> <div class="wy-side-nav-search" > <a href="index.html" class="icon icon-home"> Royalnet </a> <div role="search"> <form id="rtd-search-form" class="wy-form" action="search.html" method="get"> <input type="text" name="q" placeholder="Search docs" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation"> <ul class="current"> <li class="toctree-l1 current"><a class="current reference internal" href="#">royalnet.audio</a><ul class="simple"> </ul> </li> <li class="toctree-l1"><a class="reference internal" href="bots.html">royalnet.bots</a></li> <li class="toctree-l1"><a class="reference internal" href="commands.html">royalnet.commands</a></li> <li class="toctree-l1"><a class="reference internal" href="database.html">royalnet.database</a></li> <li class="toctree-l1"><a class="reference internal" href="network.html">royalnet.network</a></li> <li class="toctree-l1"><a class="reference internal" href="utils.html">royalnet.utils</a></li> <li class="toctree-l1"><a class="reference internal" href="error.html">royalnet.error</a></li> </ul> </div> </div> </nav> <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"> <nav class="wy-nav-top" aria-label="top navigation"> <i data-toggle="wy-nav-top" class="fa fa-bars"></i> <a href="index.html">Royalnet</a> </nav> <div class="wy-nav-content"> <div class="rst-content"> <div role="navigation" aria-label="breadcrumbs navigation"> <ul class="wy-breadcrumbs"> <li><a href="index.html">Docs</a> »</li> <li>royalnet.audio</li> <li class="wy-breadcrumbs-aside"> <a href="_sources/audio.rst.txt" rel="nofollow"> View page source</a> </li> </ul> <hr/> </div> <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article"> <div itemprop="articleBody"> <div class="section" id="royalnet-audio"> <h1>royalnet.audio<a class="headerlink" href="#royalnet-audio" title="Permalink to this headline">¶</a></h1> <div class="toctree-wrapper compound"> </div> <span class="target" id="module-royalnet.audio"></span><p>Video and audio downloading related classes, mainly used for Discord voice bots.</p> <dl class="class"> <dt id="royalnet.audio.PlayMode"> <em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">PlayMode</code><a class="headerlink" href="#royalnet.audio.PlayMode" title="Permalink to this definition">¶</a></dt> <dd><p>The base class for a PlayMode, such as <a class="reference internal" href="#royalnet.audio.Playlist" title="royalnet.audio.Playlist"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.Playlist</span></code></a>. Inherit from this class if you want to create a custom PlayMode.</p> <dl class="method"> <dt id="royalnet.audio.PlayMode.__init__"> <code class="descname">__init__</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.PlayMode.__init__" title="Permalink to this definition">¶</a></dt> <dd><p>Create a new PlayMode and initialize the generator inside.</p> </dd></dl> <dl class="method"> <dt id="royalnet.audio.PlayMode._generate_generator"> <code class="descname">_generate_generator</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.PlayMode._generate_generator" title="Permalink to this definition">¶</a></dt> <dd><p>Factory function for an async generator that changes the <code class="docutils literal notranslate"><span class="pre">now_playing</span></code> property either to a <code class="xref py py-class docutils literal notranslate"><span class="pre">discord.audio.RoyalPCMAudio</span></code> or to <code class="docutils literal notranslate"><span class="pre">None</span></code>, then yields the value it changed it to.</p> <dl class="field-list simple"> <dt class="field-odd">Yields</dt> <dd class="field-odd"><p>The <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> to be played next.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.PlayMode.add"> <code class="descname">add</code><span class="sig-paren">(</span><em>item: royalnet.audio.royalpcmaudio.RoyalPCMAudio</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#royalnet.audio.PlayMode.add" title="Permalink to this definition">¶</a></dt> <dd><p>Add a new <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> to the PlayMode.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>item</strong> – The item to add to the PlayMode.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.PlayMode.delete"> <code class="descname">delete</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → None<a class="headerlink" href="#royalnet.audio.PlayMode.delete" title="Permalink to this definition">¶</a></dt> <dd><p>Delete all <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> contained inside this PlayMode.</p> </dd></dl> <dl class="method"> <dt id="royalnet.audio.PlayMode.next"> <code class="descname">next</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Optional[royalnet.audio.royalpcmaudio.RoyalPCMAudio]<a class="headerlink" href="#royalnet.audio.PlayMode.next" title="Permalink to this definition">¶</a></dt> <dd><p>Get the next <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> from the list and advance it.</p> <dl class="field-list simple"> <dt class="field-odd">Returns</dt> <dd class="field-odd"><p>The next <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a>.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.PlayMode.videos_left"> <code class="descname">videos_left</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Union[int, float]<a class="headerlink" href="#royalnet.audio.PlayMode.videos_left" title="Permalink to this definition">¶</a></dt> <dd><p>Return the number of videos left in the PlayMode.</p> <dl class="field-list simple"> <dt class="field-odd">Returns</dt> <dd class="field-odd"><p>Usually a <a class="reference external" href="https://docs.python.org/3.7/library/functions.html#int" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>, but may return also <a class="reference external" href="https://docs.python.org/3.7/library/math.html#math.inf" title="(in Python v3.7)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">math.inf</span></code></a> if the PlayMode is infinite.</p> </dd> </dl> </dd></dl> </dd></dl> <dl class="class"> <dt id="royalnet.audio.Playlist"> <em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">Playlist</code><span class="sig-paren">(</span><em>starting_list: List[royalnet.audio.royalpcmaudio.RoyalPCMAudio] = None</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.Playlist" title="Permalink to this definition">¶</a></dt> <dd><p>A video list. <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> played are removed from the list.</p> <dl class="method"> <dt id="royalnet.audio.Playlist.__init__"> <code class="descname">__init__</code><span class="sig-paren">(</span><em>starting_list: List[royalnet.audio.royalpcmaudio.RoyalPCMAudio] = None</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.Playlist.__init__" title="Permalink to this definition">¶</a></dt> <dd><p>Create a new Playlist.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>starting_list</strong> – A list of items with which the Playlist will be created.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.Playlist._generate_generator"> <code class="descname">_generate_generator</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.Playlist._generate_generator" title="Permalink to this definition">¶</a></dt> <dd><p>Factory function for an async generator that changes the <code class="docutils literal notranslate"><span class="pre">now_playing</span></code> property either to a <code class="xref py py-class docutils literal notranslate"><span class="pre">discord.audio.RoyalPCMAudio</span></code> or to <code class="docutils literal notranslate"><span class="pre">None</span></code>, then yields the value it changed it to.</p> <dl class="field-list simple"> <dt class="field-odd">Yields</dt> <dd class="field-odd"><p>The <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> to be played next.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.Playlist.add"> <code class="descname">add</code><span class="sig-paren">(</span><em>item</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#royalnet.audio.Playlist.add" title="Permalink to this definition">¶</a></dt> <dd><p>Add a new <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> to the PlayMode.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>item</strong> – The item to add to the PlayMode.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.Playlist.delete"> <code class="descname">delete</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → None<a class="headerlink" href="#royalnet.audio.Playlist.delete" title="Permalink to this definition">¶</a></dt> <dd><p>Delete all <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> contained inside this PlayMode.</p> </dd></dl> <dl class="method"> <dt id="royalnet.audio.Playlist.videos_left"> <code class="descname">videos_left</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Union[int, float]<a class="headerlink" href="#royalnet.audio.Playlist.videos_left" title="Permalink to this definition">¶</a></dt> <dd><p>Return the number of videos left in the PlayMode.</p> <dl class="field-list simple"> <dt class="field-odd">Returns</dt> <dd class="field-odd"><p>Usually a <a class="reference external" href="https://docs.python.org/3.7/library/functions.html#int" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>, but may return also <a class="reference external" href="https://docs.python.org/3.7/library/math.html#math.inf" title="(in Python v3.7)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">math.inf</span></code></a> if the PlayMode is infinite.</p> </dd> </dl> </dd></dl> </dd></dl> <dl class="class"> <dt id="royalnet.audio.Pool"> <em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">Pool</code><span class="sig-paren">(</span><em>starting_pool: List[royalnet.audio.royalpcmaudio.RoyalPCMAudio] = None</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.Pool" title="Permalink to this definition">¶</a></dt> <dd><p>A <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> pool. <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> are selected in random order and are not repeated until every song has been played at least once.</p> <dl class="method"> <dt id="royalnet.audio.Pool.__init__"> <code class="descname">__init__</code><span class="sig-paren">(</span><em>starting_pool: List[royalnet.audio.royalpcmaudio.RoyalPCMAudio] = None</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.Pool.__init__" title="Permalink to this definition">¶</a></dt> <dd><p>Create a new Pool.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>starting_pool</strong> – A list of items the Pool will be created from.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.Pool._generate_generator"> <code class="descname">_generate_generator</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.Pool._generate_generator" title="Permalink to this definition">¶</a></dt> <dd><p>Factory function for an async generator that changes the <code class="docutils literal notranslate"><span class="pre">now_playing</span></code> property either to a <code class="xref py py-class docutils literal notranslate"><span class="pre">discord.audio.RoyalPCMAudio</span></code> or to <code class="docutils literal notranslate"><span class="pre">None</span></code>, then yields the value it changed it to.</p> <dl class="field-list simple"> <dt class="field-odd">Yields</dt> <dd class="field-odd"><p>The <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> to be played next.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.Pool.add"> <code class="descname">add</code><span class="sig-paren">(</span><em>item</em><span class="sig-paren">)</span> → None<a class="headerlink" href="#royalnet.audio.Pool.add" title="Permalink to this definition">¶</a></dt> <dd><p>Add a new <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> to the PlayMode.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>item</strong> – The item to add to the PlayMode.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.Pool.delete"> <code class="descname">delete</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → None<a class="headerlink" href="#royalnet.audio.Pool.delete" title="Permalink to this definition">¶</a></dt> <dd><p>Delete all <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio" title="royalnet.audio.RoyalPCMAudio"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio</span></code></a> contained inside this PlayMode.</p> </dd></dl> <dl class="method"> <dt id="royalnet.audio.Pool.videos_left"> <code class="descname">videos_left</code><span class="sig-paren">(</span><span class="sig-paren">)</span> → Union[int, float]<a class="headerlink" href="#royalnet.audio.Pool.videos_left" title="Permalink to this definition">¶</a></dt> <dd><p>Return the number of videos left in the PlayMode.</p> <dl class="field-list simple"> <dt class="field-odd">Returns</dt> <dd class="field-odd"><p>Usually a <a class="reference external" href="https://docs.python.org/3.7/library/functions.html#int" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>, but may return also <a class="reference external" href="https://docs.python.org/3.7/library/math.html#math.inf" title="(in Python v3.7)"><code class="xref py py-obj docutils literal notranslate"><span class="pre">math.inf</span></code></a> if the PlayMode is infinite.</p> </dd> </dl> </dd></dl> </dd></dl> <dl class="class"> <dt id="royalnet.audio.YtdlFile"> <em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">YtdlFile</code><span class="sig-paren">(</span><em>info: royalnet.audio.youtubedl.YtdlInfo</em>, <em>outtmpl='%(title)s-%(id)s.%(ext)s'</em>, <em>**ytdl_args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.YtdlFile" title="Permalink to this definition">¶</a></dt> <dd><p>A wrapper around a youtube_dl downloaded file.</p> <dl class="method"> <dt id="royalnet.audio.YtdlFile._stop_download"> <code class="descname">_stop_download</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.YtdlFile._stop_download" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="staticmethod"> <dt id="royalnet.audio.YtdlFile.create_from_url"> <em class="property">static </em><code class="descname">create_from_url</code><span class="sig-paren">(</span><em>url</em>, <em>outtmpl='%(title)s-%(id)s.%(ext)s'</em>, <em>**ytdl_args</em><span class="sig-paren">)</span> → List[royalnet.audio.youtubedl.YtdlFile]<a class="headerlink" href="#royalnet.audio.YtdlFile.create_from_url" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="royalnet.audio.YtdlFile.delete_video_file"> <code class="descname">delete_video_file</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.YtdlFile.delete_video_file" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="attribute"> <dt id="royalnet.audio.YtdlFile.ytdl_args"> <code class="descname">ytdl_args</code><em class="property"> = {'logger': <Logger royalnet.audio.youtubedl (WARNING)>, 'no_warnings': True, 'noplaylist': True, 'quiet': True}</em><a class="headerlink" href="#royalnet.audio.YtdlFile.ytdl_args" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> </dd></dl> <dl class="class"> <dt id="royalnet.audio.YtdlInfo"> <em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">YtdlInfo</code><span class="sig-paren">(</span><em>info: Dict[str, Any]</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.YtdlInfo" title="Permalink to this definition">¶</a></dt> <dd><p>A wrapper around youtube_dl extracted info.</p> <dl class="method"> <dt id="royalnet.audio.YtdlInfo.__init__"> <code class="descname">__init__</code><span class="sig-paren">(</span><em>info: Dict[str, Any]</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.YtdlInfo.__init__" title="Permalink to this definition">¶</a></dt> <dd><p>Create a YtdlInfo from the dict returned by the <code class="xref py py-func docutils literal notranslate"><span class="pre">youtube_dl.YoutubeDL.extract_info()</span></code> function.</p> <div class="admonition warning"> <p class="admonition-title">Warning</p> <p>Does not download the info, for that use <a class="reference internal" href="#royalnet.audio.YtdlInfo.create_from_url" title="royalnet.audio.YtdlInfo.create_from_url"><code class="xref py py-func docutils literal notranslate"><span class="pre">royalnet.audio.YtdlInfo.create_from_url()</span></code></a>.</p> </div> </dd></dl> <dl class="staticmethod"> <dt id="royalnet.audio.YtdlInfo.create_from_url"> <em class="property">static </em><code class="descname">create_from_url</code><span class="sig-paren">(</span><em>url</em>, <em>**ytdl_args</em><span class="sig-paren">)</span> → List[royalnet.audio.youtubedl.YtdlInfo]<a class="headerlink" href="#royalnet.audio.YtdlInfo.create_from_url" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="royalnet.audio.YtdlInfo.download"> <code class="descname">download</code><span class="sig-paren">(</span><em>outtmpl='%(title)s-%(id)s.%(ext)s'</em>, <em>**ytdl_args</em><span class="sig-paren">)</span> → royalnet.audio.youtubedl.YtdlFile<a class="headerlink" href="#royalnet.audio.YtdlInfo.download" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> </dd></dl> <dl class="class"> <dt id="royalnet.audio.RoyalPCMFile"> <em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">RoyalPCMFile</code><span class="sig-paren">(</span><em>info: royalnet.audio.youtubedl.YtdlInfo</em>, <em>**ytdl_args</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.RoyalPCMFile" title="Permalink to this definition">¶</a></dt> <dd><dl class="attribute"> <dt id="royalnet.audio.RoyalPCMFile.audio_filename"> <code class="descname">audio_filename</code><a class="headerlink" href="#royalnet.audio.RoyalPCMFile.audio_filename" title="Permalink to this definition">¶</a></dt> <dd><p>Returns: The name of the downloaded and PCM-converted audio file.</p> </dd></dl> <dl class="staticmethod"> <dt id="royalnet.audio.RoyalPCMFile.create_from_url"> <em class="property">static </em><code class="descname">create_from_url</code><span class="sig-paren">(</span><em>url: str</em>, <em>**ytdl_args</em><span class="sig-paren">)</span> → List[royalnet.audio.royalpcmfile.RoyalPCMFile]<a class="headerlink" href="#royalnet.audio.RoyalPCMFile.create_from_url" title="Permalink to this definition">¶</a></dt> <dd><p>Download a file with youtube_dl and create a list of <code class="xref py py-class docutils literal notranslate"><span class="pre">discord.audio.RoyalPCMFile</span></code>.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>url</strong> – The url of the file to download.</p></li> <li><p><strong>ytdl_args</strong> – Extra arguments to be passed to YoutubeDL while downloading.</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>A <a class="reference external" href="https://docs.python.org/3.7/library/stdtypes.html#list" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> of RoyalPCMAudios, each corresponding to a downloaded video.</p> </dd> </dl> </dd></dl> <dl class="staticmethod"> <dt id="royalnet.audio.RoyalPCMFile.create_from_ytsearch"> <em class="property">static </em><code class="descname">create_from_ytsearch</code><span class="sig-paren">(</span><em>search: str</em>, <em>amount: int = 1</em>, <em>**ytdl_args</em><span class="sig-paren">)</span> → List[royalnet.audio.royalpcmfile.RoyalPCMFile]<a class="headerlink" href="#royalnet.audio.RoyalPCMFile.create_from_ytsearch" title="Permalink to this definition">¶</a></dt> <dd><p>Search a string on YouTube and download the first <code class="docutils literal notranslate"><span class="pre">amount</span></code> number of videos, then download those with youtube_dl and create a list of <code class="xref py py-class docutils literal notranslate"><span class="pre">discord.audio.RoyalPCMFile</span></code>.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>search</strong> – The string to search on YouTube.</p></li> <li><p><strong>amount</strong> – The number of videos to download.</p></li> <li><p><strong>ytdl_args</strong> – Extra arguments to be passed to YoutubeDL while downloading.</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>A <a class="reference external" href="https://docs.python.org/3.7/library/stdtypes.html#list" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> of RoyalPCMFiles, each corresponding to a downloaded video.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.RoyalPCMFile.delete_audio_file"> <code class="descname">delete_audio_file</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.RoyalPCMFile.delete_audio_file" title="Permalink to this definition">¶</a></dt> <dd><p>Delete the PCM-converted audio file.</p> </dd></dl> <dl class="attribute"> <dt id="royalnet.audio.RoyalPCMFile.ytdl_args"> <code class="descname">ytdl_args</code><em class="property"> = {'format': 'bestaudio'}</em><a class="headerlink" href="#royalnet.audio.RoyalPCMFile.ytdl_args" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="attribute"> <dt id="royalnet.audio.RoyalPCMFile.ytdl_filename"> <code class="descname">ytdl_filename</code><a class="headerlink" href="#royalnet.audio.RoyalPCMFile.ytdl_filename" title="Permalink to this definition">¶</a></dt> <dd><dl class="field-list simple"> <dt class="field-odd">Returns</dt> <dd class="field-odd"><p>The name of the downloaded video file, as a <a class="reference external" href="https://docs.python.org/3.7/library/stdtypes.html#str" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>.</p> </dd> </dl> <div class="admonition warning"> <p class="admonition-title">Warning</p> <p>It’s going to be deleted as soon as the <code class="xref py py-func docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMFile.__init__()</span></code> function has completed, so it’s probably not going to be very useful…</p> </div> </dd></dl> </dd></dl> <dl class="class"> <dt id="royalnet.audio.RoyalPCMAudio"> <em class="property">class </em><code class="descclassname">royalnet.audio.</code><code class="descname">RoyalPCMAudio</code><span class="sig-paren">(</span><em>rpf: royalnet.audio.royalpcmfile.RoyalPCMFile</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.RoyalPCMAudio" title="Permalink to this definition">¶</a></dt> <dd><p>A discord-compatible <a class="reference external" href="https://discordpy.readthedocs.io/en/latest/api.html#discord.AudioSource" title="(in discord.py v1.1.0a)"><code class="xref py py-class docutils literal notranslate"><span class="pre">discord.AudioSource</span></code></a> that keeps data in a file instead of in memory.</p> <dl class="method"> <dt id="royalnet.audio.RoyalPCMAudio.__init__"> <code class="descname">__init__</code><span class="sig-paren">(</span><em>rpf: royalnet.audio.royalpcmfile.RoyalPCMFile</em><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.RoyalPCMAudio.__init__" title="Permalink to this definition">¶</a></dt> <dd><p>Create a <code class="xref py py-class docutils literal notranslate"><span class="pre">discord.audio.RoyalPCMAudio</span></code> from a <a class="reference internal" href="#royalnet.audio.RoyalPCMFile" title="royalnet.audio.RoyalPCMFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMFile</span></code></a>.</p> <div class="admonition warning"> <p class="admonition-title">Warning</p> <p>Not recommended, use <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio.create_from_url" title="royalnet.audio.RoyalPCMAudio.create_from_url"><code class="xref py py-func docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio.create_from_url()</span></code></a> or <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio.create_from_ytsearch" title="royalnet.audio.RoyalPCMAudio.create_from_ytsearch"><code class="xref py py-func docutils literal notranslate"><span class="pre">royalnet.audio.RoyalPCMAudio.create_from_ytsearch()</span></code></a> instead.</p> </div> </dd></dl> <dl class="staticmethod"> <dt id="royalnet.audio.RoyalPCMAudio.create_from_url"> <em class="property">static </em><code class="descname">create_from_url</code><span class="sig-paren">(</span><em>url: str</em><span class="sig-paren">)</span> → List[royalnet.audio.royalpcmaudio.RoyalPCMAudio]<a class="headerlink" href="#royalnet.audio.RoyalPCMAudio.create_from_url" title="Permalink to this definition">¶</a></dt> <dd><p>Download a file with youtube_dl and create a list of RoyalPCMAudios.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><p><strong>url</strong> – The url of the file to download.</p> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>A <a class="reference external" href="https://docs.python.org/3.7/library/stdtypes.html#list" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> of RoyalPCMAudios, each corresponding to a downloaded video.</p> </dd> </dl> </dd></dl> <dl class="staticmethod"> <dt id="royalnet.audio.RoyalPCMAudio.create_from_ytsearch"> <em class="property">static </em><code class="descname">create_from_ytsearch</code><span class="sig-paren">(</span><em>search: str</em>, <em>amount: int = 1</em><span class="sig-paren">)</span> → List[royalnet.audio.royalpcmaudio.RoyalPCMAudio]<a class="headerlink" href="#royalnet.audio.RoyalPCMAudio.create_from_ytsearch" title="Permalink to this definition">¶</a></dt> <dd><p>Search a string on YouTube and download the first <code class="docutils literal notranslate"><span class="pre">amount</span></code> number of videos, then download those with youtube_dl and create a list of RoyalPCMAudios.</p> <dl class="field-list simple"> <dt class="field-odd">Parameters</dt> <dd class="field-odd"><ul class="simple"> <li><p><strong>search</strong> – The string to search on YouTube.</p></li> <li><p><strong>amount</strong> – The number of videos to download.</p></li> </ul> </dd> <dt class="field-even">Returns</dt> <dd class="field-even"><p>A <a class="reference external" href="https://docs.python.org/3.7/library/stdtypes.html#list" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> of RoyalPCMAudios, each corresponding to a downloaded video.</p> </dd> </dl> </dd></dl> <dl class="method"> <dt id="royalnet.audio.RoyalPCMAudio.delete"> <code class="descname">delete</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.RoyalPCMAudio.delete" title="Permalink to this definition">¶</a></dt> <dd><p>Permanently delete the downloaded file.</p> </dd></dl> <dl class="method"> <dt id="royalnet.audio.RoyalPCMAudio.is_opus"> <code class="descname">is_opus</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.RoyalPCMAudio.is_opus" title="Permalink to this definition">¶</a></dt> <dd><p>Checks if the audio source is already encoded in Opus.</p> <p>Defaults to <code class="docutils literal notranslate"><span class="pre">False</span></code>.</p> </dd></dl> <dl class="method"> <dt id="royalnet.audio.RoyalPCMAudio.read"> <code class="descname">read</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#royalnet.audio.RoyalPCMAudio.read" title="Permalink to this definition">¶</a></dt> <dd><p>Reads 20ms worth of audio.</p> <p>Subclasses must implement this.</p> <p>If the audio is complete, then returning an empty <span class="xref std std-term">py:bytes-like object</span> to signal this is the way to do so.</p> <p>If <a class="reference internal" href="#royalnet.audio.RoyalPCMAudio.is_opus" title="royalnet.audio.RoyalPCMAudio.is_opus"><code class="xref py py-meth docutils literal notranslate"><span class="pre">is_opus()</span></code></a> method returns <code class="docutils literal notranslate"><span class="pre">True</span></code>, then it must return 20ms worth of Opus encoded audio. Otherwise, it must be 20ms worth of 16-bit 48KHz stereo PCM, which is about 3,840 bytes per frame (20ms worth of audio).</p> <dl class="field-list simple"> <dt class="field-odd">Returns</dt> <dd class="field-odd"><p>A bytes like object that represents the PCM or Opus data.</p> </dd> <dt class="field-even">Return type</dt> <dd class="field-even"><p><a class="reference external" href="https://docs.python.org/3.7/library/stdtypes.html#bytes" title="(in Python v3.7)"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a></p> </dd> </dl> </dd></dl> </dd></dl> </div> </div> </div> <footer> <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation"> <a href="bots.html" class="btn btn-neutral float-right" title="royalnet.bots" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a> <a href="index.html" class="btn btn-neutral float-left" title="royalnet" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a> </div> <hr/> <div role="contentinfo"> <p> © Copyright 2019, Stefano Pigozzi </p> </div> Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. </footer> </div> </div> </section> </div> <script type="text/javascript"> jQuery(function () { SphinxRtdTheme.Navigation.enable(true); }); </script> </body> </html>