This file is indexed.

/usr/share/doc/python-musicbrainzngs/html/usage.html is in python-musicbrainzngs-doc 0.6-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Usage &#8212; musicbrainzngs 0.6 documentation</title>
    <link rel="stylesheet" href="_static//default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '0.6',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true,
        SOURCELINK_SUFFIX: '.txt'
      };
    </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>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="API" href="api.html" />
    <link rel="prev" title="Installation" href="installation.html" /> 
  </head>
  <body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="api.html" title="API"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="installation.html" title="Installation"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">musicbrainzngs 0.6 documentation</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="usage">
<h1>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h1>
<p>In general you need to set a useragent for your application,
start searches to get to know corresponding MusicBrainz IDs
and then retrieve information about these entities.</p>
<p>The data is returned in form of a <code class="xref py py-class docutils literal"><span class="pre">dict</span></code>.</p>
<p>If you also want to submit data,
then you must authenticate as a MusicBrainz user.</p>
<p>This part of the documentation will give you usage examples.
For an overview of available functions you can have a look at
the <a class="reference internal" href="api.html"><span class="doc">API</span></a>.</p>
<div class="section" id="identification">
<h2>Identification<a class="headerlink" href="#identification" title="Permalink to this headline"></a></h2>
<p>To access the MusicBrainz webservice through this library, you <a class="reference external" href="http://musicbrainz.org/doc/XML_Web_Service/Version_2#Identifying_your_application_to_the_MusicBrainz_Web_Service">need to
identify your application</a>
by setting the useragent header made in HTTP requests to one that is unique to
your application.</p>
<p>To ease this, the convenience function <a class="reference internal" href="api.html#musicbrainzngs.set_useragent" title="musicbrainzngs.set_useragent"><code class="xref py py-meth docutils literal"><span class="pre">musicbrainzngs.set_useragent()</span></code></a> is
provided which automatically sets the useragent based on information about the
application name, version and contact information to the format <a class="reference external" href="http://musicbrainz.org/doc/XML_Web_Service/Rate_Limiting#Provide_meaningful_User-Agent_strings">recommended by
MusicBrainz</a>.</p>
<p>If a request is made without setting the useragent beforehand, a
<a class="reference internal" href="api.html#musicbrainzngs.UsageError" title="musicbrainzngs.UsageError"><code class="xref py py-exc docutils literal"><span class="pre">musicbrainzngs.UsageError</span></code></a> will be raised.</p>
</div>
<div class="section" id="authentication">
<h2>Authentication<a class="headerlink" href="#authentication" title="Permalink to this headline"></a></h2>
<p>Certain calls to the webservice require user authentication prior to the call
itself. The affected functions state this requirement in their documentation.
The user and password used for authentication are the same as for the
MusicBrainz website itself and can be set with the <a class="reference internal" href="api.html#musicbrainzngs.auth" title="musicbrainzngs.auth"><code class="xref py py-meth docutils literal"><span class="pre">musicbrainzngs.auth()</span></code></a>
method. After calling this function, the credentials will be saved and
automaticall used by all functions requiring them.</p>
<p>If a method requiring authentication is called without authenticating, a
<a class="reference internal" href="api.html#musicbrainzngs.UsageError" title="musicbrainzngs.UsageError"><code class="xref py py-exc docutils literal"><span class="pre">musicbrainzngs.UsageError</span></code></a> will be raised.</p>
<p>If the credentials provided are wrong and the server returns a status code of
401, a <a class="reference internal" href="api.html#musicbrainzngs.AuthenticationError" title="musicbrainzngs.AuthenticationError"><code class="xref py py-exc docutils literal"><span class="pre">musicbrainzngs.AuthenticationError</span></code></a> will be raised.</p>
</div>
<div class="section" id="getting-data">
<h2>Getting Data<a class="headerlink" href="#getting-data" title="Permalink to this headline"></a></h2>
<div class="section" id="regular-musicbrainz-data">
<h3>Regular MusicBrainz Data<a class="headerlink" href="#regular-musicbrainz-data" title="Permalink to this headline"></a></h3>
<p>You can get MusicBrainz entities as a <code class="xref py py-class docutils literal"><span class="pre">dict</span></code>
when retrieving them with some form of identifier.
An example using <a class="reference internal" href="api.html#musicbrainzngs.get_artist_by_id" title="musicbrainzngs.get_artist_by_id"><code class="xref py py-func docutils literal"><span class="pre">musicbrainzngs.get_artist_by_id()</span></code></a>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">artist_id</span> <span class="o">=</span> <span class="s2">&quot;c5c2ea1c-4bde-4f4d-bd0b-47b200bf99d6&quot;</span>
<span class="k">try</span><span class="p">:</span>
    <span class="n">result</span> <span class="o">=</span> <span class="n">musicbrainzngs</span><span class="o">.</span><span class="n">get_artist_by_id</span><span class="p">(</span><span class="n">artist_id</span><span class="p">)</span>
<span class="k">except</span> <span class="n">WebServiceError</span> <span class="k">as</span> <span class="n">exc</span><span class="p">:</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Something went wrong with the request: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">exc</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
    <span class="n">artist</span> <span class="o">=</span> <span class="n">result</span><span class="p">[</span><span class="s2">&quot;artist&quot;</span><span class="p">]</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;name:</span><span class="se">\t\t</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">artist</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">])</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;sort name:</span><span class="se">\t</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">artist</span><span class="p">[</span><span class="s2">&quot;sort-name&quot;</span><span class="p">])</span>
</pre></div>
</div>
<p>You can get more information about entities connected to the artist
with adding <cite>includes</cite> and you filter releases and release_groups:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">result</span> <span class="o">=</span> <span class="n">musicbrainzngs</span><span class="o">.</span><span class="n">get_artist_by_id</span><span class="p">(</span><span class="n">artist_id</span><span class="p">,</span>
              <span class="n">includes</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;release-groups&quot;</span><span class="p">],</span> <span class="n">release_type</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;album&quot;</span><span class="p">,</span> <span class="s2">&quot;ep&quot;</span><span class="p">])</span>
<span class="k">for</span> <span class="n">release_group</span> <span class="ow">in</span> <span class="n">result</span><span class="p">[</span><span class="s2">&quot;artist&quot;</span><span class="p">][</span><span class="s2">&quot;release-group-list&quot;</span><span class="p">]:</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{title}</span><span class="s2"> (</span><span class="si">{type}</span><span class="s2">)&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">title</span><span class="o">=</span><span class="n">release_group</span><span class="p">[</span><span class="s2">&quot;title&quot;</span><span class="p">],</span>
                                    <span class="nb">type</span><span class="o">=</span><span class="n">release_group</span><span class="p">[</span><span class="s2">&quot;type&quot;</span><span class="p">]))</span>
</pre></div>
</div>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last">Compilations are also of primary type “album”.
You have to filter these out manually if you don’t want them.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">You can only get at most 25 release groups using this method.
If you want to fetch all release groups you will have to
<a class="reference external" href="browsing">browse</a>.</p>
</div>
</div>
<div class="section" id="cover-art-data">
<h3>Cover Art Data<a class="headerlink" href="#cover-art-data" title="Permalink to this headline"></a></h3>
<p>This library includes a few methods to access data from the <a class="reference external" href="https://coverartarchive.org/">Cover Art Archive</a> which has a <a class="reference external" href="https://musicbrainz.org/doc/Cover_Art_Archive/API">documented API
documentation</a></p>
<p>Both <a class="reference internal" href="api.html#musicbrainzngs.get_image_list" title="musicbrainzngs.get_image_list"><code class="xref py py-func docutils literal"><span class="pre">musicbrainzngs.get_image_list()</span></code></a> and
<a class="reference internal" href="api.html#musicbrainzngs.get_release_group_image_list" title="musicbrainzngs.get_release_group_image_list"><code class="xref py py-func docutils literal"><span class="pre">musicbrainzngs.get_release_group_image_list()</span></code></a> return the deserialized
cover art listing for a <a class="reference external" href="https://musicbrainz.org/doc/Cover_Art_Archive/API#.2Frelease.2F.7Bmbid.7D.2F">release</a>
or <a class="reference external" href="https://musicbrainz.org/doc/Cover_Art_Archive/API#.2Frelease-group.2F.7Bmbid.7D.2F">release group</a>.
To find out whether a release
has an approved front image, you could use the following example code:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">release_id</span> <span class="o">=</span> <span class="s2">&quot;46a48e90-819b-4bed-81fa-5ca8aa33fbf3&quot;</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">musicbrainzngs</span><span class="o">.</span><span class="n">get_cover_art_list</span><span class="p">(</span><span class="s2">&quot;46a48e90-819b-4bed-81fa-5ca8aa33fbf3&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">image</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="s2">&quot;images&quot;</span><span class="p">]:</span>
    <span class="k">if</span> <span class="s2">&quot;Front&quot;</span> <span class="ow">in</span> <span class="n">image</span><span class="p">[</span><span class="s2">&quot;types&quot;</span><span class="p">]</span> <span class="ow">and</span> <span class="n">image</span><span class="p">[</span><span class="s2">&quot;approved&quot;</span><span class="p">]:</span>
        <span class="nb">print</span> <span class="s2">&quot;</span><span class="si">%s</span><span class="s2"> is an approved front image!&quot;</span> <span class="o">%</span> <span class="n">image</span><span class="p">[</span><span class="s2">&quot;thumbnails&quot;</span><span class="p">][</span><span class="s2">&quot;large&quot;</span><span class="p">]</span>
        <span class="k">break</span>
</pre></div>
</div>
<p>To retrieve an image itself, use <a class="reference internal" href="api.html#musicbrainzngs.get_image" title="musicbrainzngs.get_image"><code class="xref py py-func docutils literal"><span class="pre">musicbrainzngs.get_image()</span></code></a>. A
few convenience functions like <a class="reference internal" href="api.html#musicbrainzngs.get_image_front" title="musicbrainzngs.get_image_front"><code class="xref py py-func docutils literal"><span class="pre">musicbrainzngs.get_image_front()</span></code></a>
are provided to allow easy access to often requested images.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">There is no upper bound for the size of images uploaded to the
Cover Art Archive and downloading an image will return the binary data in
memory. Consider using the <code class="xref py py-mod docutils literal"><span class="pre">tempfile</span></code> module or similar
techniques to save images to disk as soon as possible.</p>
</div>
</div>
</div>
<div class="section" id="searching">
<h2>Searching<a class="headerlink" href="#searching" title="Permalink to this headline"></a></h2>
<p>When you don’t know the MusicBrainz IDs yet, you have to start a search.
Using <a class="reference internal" href="api.html#musicbrainzngs.search_artists" title="musicbrainzngs.search_artists"><code class="xref py py-func docutils literal"><span class="pre">musicbrainzngs.search_artists()</span></code></a>:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">result</span> <span class="o">=</span> <span class="n">musicbrainzngs</span><span class="o">.</span><span class="n">search_artists</span><span class="p">(</span><span class="n">artist</span><span class="o">=</span><span class="s2">&quot;xx&quot;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s2">&quot;group&quot;</span><span class="p">,</span>
                                       <span class="n">country</span><span class="o">=</span><span class="s2">&quot;GB&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">artist</span> <span class="ow">in</span> <span class="n">result</span><span class="p">[</span><span class="s1">&#39;artist-list&#39;</span><span class="p">]:</span>
    <span class="nb">print</span><span class="p">(</span><span class="sa">u</span><span class="s2">&quot;</span><span class="si">{id}</span><span class="s2">: </span><span class="si">{name}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">id</span><span class="o">=</span><span class="n">artist</span><span class="p">[</span><span class="s1">&#39;id&#39;</span><span class="p">],</span> <span class="n">name</span><span class="o">=</span><span class="n">artist</span><span class="p">[</span><span class="s2">&quot;name&quot;</span><span class="p">]))</span>
</pre></div>
</div>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last">Musicbrainzngs returns unicode strings.
It’s up to you to make sure Python (2) doesn’t try to convert these
to ascii again. In the example we force a unicode literal for print.
Python 3 works without fixes like these.</p>
</div>
<p>You can also use the query without specifying the search fields:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">musicbrainzngs</span><span class="o">.</span><span class="n">search_release_groups</span><span class="p">(</span><span class="s2">&quot;the clash london calling&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>The query and the search fields can also be used at the same time.</p>
</div>
<div class="section" id="browsing">
<h2>Browsing<a class="headerlink" href="#browsing" title="Permalink to this headline"></a></h2>
<p>When you want to fetch a list of entities greater than 25,
you have to use one of the browse functions.
Not only can you specify a <cite>limit</cite> as high as 100,
but you can also specify an <cite>offset</cite> to get the complete list
in multiple requests.</p>
<p>An example would be using <a class="reference internal" href="api.html#musicbrainzngs.browse_release_groups" title="musicbrainzngs.browse_release_groups"><code class="xref py py-func docutils literal"><span class="pre">musicbrainzngs.browse_release_groups()</span></code></a>
to get all releases for a label:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;71247f6b-fd24-4a56-89a2-23512f006f0c&quot;</span>
<span class="n">limit</span> <span class="o">=</span> <span class="mi">100</span>
<span class="n">offset</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">releases</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">page</span> <span class="o">=</span> <span class="mi">1</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;fetching page number </span><span class="si">%d</span><span class="s2">..&quot;</span> <span class="o">%</span> <span class="n">page</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">musicbrainzngs</span><span class="o">.</span><span class="n">browse_releases</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">,</span> <span class="n">includes</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;labels&quot;</span><span class="p">],</span>
                <span class="n">release_type</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;album&quot;</span><span class="p">],</span> <span class="n">limit</span><span class="o">=</span><span class="n">limit</span><span class="p">)</span>
<span class="n">page_releases</span> <span class="o">=</span> <span class="n">result</span><span class="p">[</span><span class="s1">&#39;release-list&#39;</span><span class="p">]</span>
<span class="n">releases</span> <span class="o">+=</span> <span class="n">page_releases</span>
<span class="c1"># release-count is only available starting with musicbrainzngs 0.5</span>
<span class="k">if</span> <span class="s2">&quot;release-count&quot;</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
        <span class="n">count</span> <span class="o">=</span> <span class="n">result</span><span class="p">[</span><span class="s1">&#39;release-count&#39;</span><span class="p">]</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="k">while</span> <span class="nb">len</span><span class="p">(</span><span class="n">page_releases</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="n">limit</span><span class="p">:</span>
    <span class="n">offset</span> <span class="o">+=</span> <span class="n">limit</span>
    <span class="n">page</span> <span class="o">+=</span> <span class="mi">1</span>
    <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;fetching page number </span><span class="si">%d</span><span class="s2">..&quot;</span> <span class="o">%</span> <span class="n">page</span><span class="p">)</span>
    <span class="n">result</span> <span class="o">=</span> <span class="n">musicbrainzngs</span><span class="o">.</span><span class="n">browse_releases</span><span class="p">(</span><span class="n">label</span><span class="o">=</span><span class="n">label</span><span class="p">,</span> <span class="n">includes</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;labels&quot;</span><span class="p">],</span>
                        <span class="n">release_type</span><span class="o">=</span><span class="p">[</span><span class="s2">&quot;album&quot;</span><span class="p">],</span> <span class="n">limit</span><span class="o">=</span><span class="n">limit</span><span class="p">,</span> <span class="n">offset</span><span class="o">=</span><span class="n">offset</span><span class="p">)</span>
    <span class="n">page_releases</span> <span class="o">=</span> <span class="n">result</span><span class="p">[</span><span class="s1">&#39;release-list&#39;</span><span class="p">]</span>
    <span class="n">releases</span> <span class="o">+=</span> <span class="n">page_releases</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;&quot;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">release</span> <span class="ow">in</span> <span class="n">releases</span><span class="p">:</span>
    <span class="k">for</span> <span class="n">label_info</span> <span class="ow">in</span> <span class="n">release</span><span class="p">[</span><span class="s1">&#39;label-info-list&#39;</span><span class="p">]:</span>
        <span class="n">catnum</span> <span class="o">=</span> <span class="n">label_info</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;catalog-number&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">label_info</span><span class="p">[</span><span class="s1">&#39;label&#39;</span><span class="p">][</span><span class="s1">&#39;id&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="n">label</span> <span class="ow">and</span> <span class="n">catnum</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{catnum:&gt;17}</span><span class="s2">: </span><span class="si">{date:10}</span><span class="s2"> </span><span class="si">{title}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">catnum</span><span class="o">=</span><span class="n">catnum</span><span class="p">,</span>
                        <span class="n">date</span><span class="o">=</span><span class="n">release</span><span class="p">[</span><span class="s1">&#39;date&#39;</span><span class="p">],</span> <span class="n">title</span><span class="o">=</span><span class="n">release</span><span class="p">[</span><span class="s1">&#39;title&#39;</span><span class="p">]))</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="si">%d</span><span class="s2"> releases on  </span><span class="si">%d</span><span class="s2"> pages&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">releases</span><span class="p">),</span> <span class="n">page</span><span class="p">))</span>
</pre></div>
</div>
<div class="admonition tip">
<p class="first admonition-title">Tip</p>
<p class="last">You should always try to filter in the query, when possible,
rather than fetching everything and filtering afterwards.
This will make your application faster
since web service requests are throttled.
In the example we filter by <cite>release_type</cite>.</p>
</div>
</div>
<div class="section" id="submitting">
<h2>Submitting<a class="headerlink" href="#submitting" title="Permalink to this headline"></a></h2>
<p>You can also submit data using musicbrainzngs.
Please use <a class="reference internal" href="api.html#musicbrainzngs.set_hostname" title="musicbrainzngs.set_hostname"><code class="xref py py-func docutils literal"><span class="pre">musicbrainzngs.set_hostname()</span></code></a> to set the host to
test.musicbrainz.org when testing the submission part of your application.</p>
<p><a class="reference internal" href="#authentication">Authentication</a> is necessary to submit any data to MusicBrainz.</p>
<p>An example using <a class="reference internal" href="api.html#musicbrainzngs.submit_barcodes" title="musicbrainzngs.submit_barcodes"><code class="xref py py-func docutils literal"><span class="pre">musicbrainzngs.submit_barcodes()</span></code></a> looks like this:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">musicbrainzngs</span><span class="o">.</span><span class="n">set_hostname</span><span class="p">(</span><span class="s2">&quot;test.musicbrainz.org&quot;</span><span class="p">)</span>
<span class="n">musicbrainzngs</span><span class="o">.</span><span class="n">auth</span><span class="p">(</span><span class="s2">&quot;test&quot;</span><span class="p">,</span> <span class="s2">&quot;mb&quot;</span><span class="p">)</span>

<span class="n">barcodes</span> <span class="o">=</span> <span class="p">{</span>
    <span class="s2">&quot;174a5513-73d1-3c9d-a316-3c1c179e35f8&quot;</span><span class="p">:</span> <span class="s2">&quot;5099749534728&quot;</span><span class="p">,</span>
    <span class="s2">&quot;838952af-600d-3f51-84d5-941d15880400&quot;</span><span class="p">:</span> <span class="s2">&quot;602517737280&quot;</span>
<span class="p">}</span>
<span class="n">musicbrainzngs</span><span class="o">.</span><span class="n">submit_barcodes</span><span class="p">(</span><span class="n">barcodes</span><span class="p">)</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="api.html#api-submitting"><span class="std std-ref">Submitting</span></a> in the API for other possibilites.</p>
</div>
<div class="section" id="more-examples">
<h2>More Examples<a class="headerlink" href="#more-examples" title="Permalink to this headline"></a></h2>
<p>You can find some examples for using <cite>musicbrainzngs</cite> in the
<a class="reference external" href="https://github.com/alastair/python-musicbrainzngs/tree/master/examples">examples directory</a>.</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Usage</a><ul>
<li><a class="reference internal" href="#identification">Identification</a></li>
<li><a class="reference internal" href="#authentication">Authentication</a></li>
<li><a class="reference internal" href="#getting-data">Getting Data</a><ul>
<li><a class="reference internal" href="#regular-musicbrainz-data">Regular MusicBrainz Data</a></li>
<li><a class="reference internal" href="#cover-art-data">Cover Art Data</a></li>
</ul>
</li>
<li><a class="reference internal" href="#searching">Searching</a></li>
<li><a class="reference internal" href="#browsing">Browsing</a></li>
<li><a class="reference internal" href="#submitting">Submitting</a></li>
<li><a class="reference internal" href="#more-examples">More Examples</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="installation.html"
                        title="previous chapter">Installation</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="api.html"
                        title="next chapter">API</a></p>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="api.html" title="API"
             >next</a> |</li>
        <li class="right" >
          <a href="installation.html" title="Installation"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">musicbrainzngs 0.6 documentation</a> &#187;</li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2018, Alastair Porter et al.
      Last updated on February 19, 2018.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.7.
    </div>
  </body>
</html>