├── .gitignore ├── AUTHORS ├── README.rst ├── docs ├── Makefile ├── conf.py ├── index.rst └── make.bat ├── requirements.txt ├── setup.py └── songkick ├── __init__.py ├── base.py ├── connection.py ├── events ├── __init__.py ├── models.py └── query.py ├── exceptions.py ├── fields.py ├── query.py ├── setlists ├── __init__.py ├── models.py └── query.py └── utils.py /.gitignore: -------------------------------------------------------------------------------- 1 | *pyc 2 | bin/ 3 | build/ 4 | include/ 5 | lib/ 6 | src/ 7 | share/ 8 | .Python 9 | local_settings.py 10 | .DS_Store 11 | *.sql 12 | *.json 13 | *.bz2 14 | *.zip 15 | .oohembed_cache 16 | media/tracks/ 17 | media/entries/ 18 | alteredzones/search/data/ 19 | misc/ -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Matt Dennewitz -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | 2 | python-songkick 3 | =============== 4 | 5 | Wrapping Songkick's API since 2010. 6 | 7 | More documentation forthcoming, but check out the example to get started. 8 | 9 | Getting an API key 10 | ------------------ 11 | 12 | Visit http://www.songkick.com/api_key_requests/new to request an API key. 13 | 14 | Usage 15 | ----- 16 | 17 | Using this wrapper is fairly straight-forward. Right now, events, gigographies and 18 | setlists are supported. 19 | 20 | Getting a connection 21 | ~~~~~~~~~~~~~~~~~~~~ 22 | 23 | :: 24 | 25 | songkick = Songkick(api_key=[YOUR API KEY]) 26 | 27 | Querying for events 28 | ~~~~~~~~~~~~~~~~~~~ 29 | 30 | ``Songkick.events`` provides access to Songkick's event search. 31 | 32 | Event querying supports the following parameters: 33 | 34 | - ``artist_name`` 35 | - ``artist_id``, the Songkick-given artist id 36 | - ``musicbrainz_id``, a MusicBrainz id. If ``musicbrainz_id`` is 37 | given, no other artist-related query parameters are respected. 38 | - ``venue_id``, the Songkick-given venue id. There is not currently a 39 | way to programmatically search for venues. 40 | - ``min_date``, the earliest possible event date. Given as ``date``. 41 | - ``max_date``, the latest possible event date. Given as ``date``. 42 | 43 | Pagination is handled with the following parameters: 44 | 45 | - ``per_page``, the number of objects per page. 50 max. 46 | - ``page``, the page number you'd like. 47 | 48 | See TODO for pagination plans. 49 | 50 | :: 51 | 52 | # query for 10 coltrane motion events, no earlier than 1/1/2009 53 | events = songkick.events.query(artist_name='coltrane motion', 54 | per_page=10, 55 | min_date=date(2009, 1, 1)) 56 | 57 | # iterate over the list of events 58 | for event in events: 59 | print event.display_name # Coltrane Motion at Arlene's Grocery (June 2, 2010) 60 | print event.location.city # New York, NY, US 61 | print event.venue.display_name # Arlene's Grocery 62 | 63 | Querying for gigographies 64 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 65 | 66 | ``Songkick.gigography`` provides access to Songkick's gigography search. 67 | 68 | Gigography querying supports the following parameters: 69 | 70 | - ``artist_id``, the Songkick-given artist id 71 | - ``musicbrainz_id``, a MusicBrainz id. If ``musicbrainz_id`` is 72 | given, no other artist-related query parameters are respected. 73 | - ``order``, the result ordering type, ``desc`` or ``asc`` (default value). 74 | 75 | Pagination is handled with the following parameters: 76 | 77 | - ``per_page``, the number of objects per page. 50 max. 78 | - ``page``, the page number you'd like. 79 | 80 | See TODO for pagination plans. 81 | 82 | :: 83 | 84 | # query for latest Dropkick Musphys events 85 | events = songkick.gigography.query(artist_id='211206', order='desc') 86 | 87 | # iterate over the list of events 88 | for event in events: 89 | print event.display_name 90 | print event.location.city 91 | print event.venue.display_name 92 | 93 | 94 | Querying for setlists 95 | ~~~~~~~~~~~~~~~~~~~~~ 96 | 97 | ``Songkick.setlists`` provides access to Songkick's setlist 98 | catalog. 99 | 100 | Right now, Songkick's setlist API only allows querying for setlists by 101 | event id. 102 | 103 | :: 104 | 105 | # pull the setlist for event 786417, wilco @ the troxy 106 | setlist = songkick.setlists.get(id=786417) 107 | 108 | # check out whats inside 109 | print setlist.display_name # Wilco at Troxy (25 Aug 09) 110 | 111 | for song in setlist.setlist_items: 112 | print song.title # Wilco (The Song) 113 | 114 | .. note:: Songkick's API documentation is fairly out of date. I've provided a few response 115 | examples in the ``data`` dir. 116 | 117 | 118 | Requirements 119 | ------------ 120 | 121 | - python 2.6+ 122 | - httplib2 123 | - sphinx (optional, to build docs) 124 | - python-dateutil 125 | 126 | All covered in ``requirements.txt``. 127 | 128 | 129 | .. _todo: 130 | 131 | TODO 132 | ---- 133 | 134 | - Support event location search 135 | - Pagination feels incomplete, so I'd like to add an optional cursor 136 | to allow transparent page fetching. 137 | 138 | 139 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | 15 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " singlehtml to make a single large HTML file" 22 | @echo " pickle to make pickle files" 23 | @echo " json to make JSON files" 24 | @echo " htmlhelp to make HTML files and a HTML help project" 25 | @echo " qthelp to make HTML files and a qthelp project" 26 | @echo " devhelp to make HTML files and a Devhelp project" 27 | @echo " epub to make an epub" 28 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 29 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 30 | @echo " text to make text files" 31 | @echo " man to make manual pages" 32 | @echo " changes to make an overview of all changed/added/deprecated items" 33 | @echo " linkcheck to check all external links for integrity" 34 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 35 | 36 | clean: 37 | -rm -rf $(BUILDDIR)/* 38 | 39 | html: 40 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 41 | @echo 42 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 43 | 44 | dirhtml: 45 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 46 | @echo 47 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 48 | 49 | singlehtml: 50 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 51 | @echo 52 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 53 | 54 | pickle: 55 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 56 | @echo 57 | @echo "Build finished; now you can process the pickle files." 58 | 59 | json: 60 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 61 | @echo 62 | @echo "Build finished; now you can process the JSON files." 63 | 64 | htmlhelp: 65 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 66 | @echo 67 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 68 | ".hhp project file in $(BUILDDIR)/htmlhelp." 69 | 70 | qthelp: 71 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 72 | @echo 73 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 74 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 75 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/python-songkick.qhcp" 76 | @echo "To view the help file:" 77 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/python-songkick.qhc" 78 | 79 | devhelp: 80 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 81 | @echo 82 | @echo "Build finished." 83 | @echo "To view the help file:" 84 | @echo "# mkdir -p $$HOME/.local/share/devhelp/python-songkick" 85 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/python-songkick" 86 | @echo "# devhelp" 87 | 88 | epub: 89 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 90 | @echo 91 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 92 | 93 | latex: 94 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 95 | @echo 96 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 97 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 98 | "(use \`make latexpdf' here to do that automatically)." 99 | 100 | latexpdf: 101 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 102 | @echo "Running LaTeX files through pdflatex..." 103 | make -C $(BUILDDIR)/latex all-pdf 104 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 105 | 106 | text: 107 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 108 | @echo 109 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 110 | 111 | man: 112 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 113 | @echo 114 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 115 | 116 | changes: 117 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 118 | @echo 119 | @echo "The overview file is in $(BUILDDIR)/changes." 120 | 121 | linkcheck: 122 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 123 | @echo 124 | @echo "Link check complete; look for any errors in the above output " \ 125 | "or in $(BUILDDIR)/linkcheck/output.txt." 126 | 127 | doctest: 128 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 129 | @echo "Testing of doctests in the sources finished, look at the " \ 130 | "results in $(BUILDDIR)/doctest/output.txt." 131 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # python-songkick documentation build configuration file, created by 4 | # sphinx-quickstart on Fri Nov 26 18:43:20 2010. 5 | # 6 | # This file is execfile()d with the current directory set to its containing dir. 7 | # 8 | # Note that not all possible configuration values are present in this 9 | # autogenerated file. 10 | # 11 | # All configuration values have a default; values that are commented out 12 | # serve to show the default. 13 | 14 | import sys, os 15 | 16 | # If extensions (or modules to document with autodoc) are in another directory, 17 | # add these directories to sys.path here. If the directory is relative to the 18 | # documentation root, use os.path.abspath to make it absolute, like shown here. 19 | #sys.path.insert(0, os.path.abspath('.')) 20 | 21 | # -- General configuration ----------------------------------------------------- 22 | 23 | # If your documentation needs a minimal Sphinx version, state it here. 24 | #needs_sphinx = '1.0' 25 | 26 | # Add any Sphinx extension module names here, as strings. They can be extensions 27 | # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. 28 | extensions = ['sphinx.ext.todo'] 29 | 30 | # Add any paths that contain templates here, relative to this directory. 31 | templates_path = ['_templates'] 32 | 33 | # The suffix of source filenames. 34 | source_suffix = '.rst' 35 | 36 | # The encoding of source files. 37 | #source_encoding = 'utf-8-sig' 38 | 39 | # The master toctree document. 40 | master_doc = 'index' 41 | 42 | # General information about the project. 43 | project = u'python-songkick' 44 | copyright = u'2010, Matt Dennewitz' 45 | 46 | # The version info for the project you're documenting, acts as replacement for 47 | # |version| and |release|, also used in various other places throughout the 48 | # built documents. 49 | # 50 | # The short X.Y version. 51 | version = '0.1' 52 | # The full version, including alpha/beta/rc tags. 53 | release = '0.1' 54 | 55 | # The language for content autogenerated by Sphinx. Refer to documentation 56 | # for a list of supported languages. 57 | #language = None 58 | 59 | # There are two options for replacing |today|: either, you set today to some 60 | # non-false value, then it is used: 61 | #today = '' 62 | # Else, today_fmt is used as the format for a strftime call. 63 | #today_fmt = '%B %d, %Y' 64 | 65 | # List of patterns, relative to source directory, that match files and 66 | # directories to ignore when looking for source files. 67 | exclude_patterns = ['_build'] 68 | 69 | # The reST default role (used for this markup: `text`) to use for all documents. 70 | #default_role = None 71 | 72 | # If true, '()' will be appended to :func: etc. cross-reference text. 73 | #add_function_parentheses = True 74 | 75 | # If true, the current module name will be prepended to all description 76 | # unit titles (such as .. function::). 77 | #add_module_names = True 78 | 79 | # If true, sectionauthor and moduleauthor directives will be shown in the 80 | # output. They are ignored by default. 81 | #show_authors = False 82 | 83 | # The name of the Pygments (syntax highlighting) style to use. 84 | pygments_style = 'sphinx' 85 | 86 | # A list of ignored prefixes for module index sorting. 87 | #modindex_common_prefix = [] 88 | 89 | 90 | # -- Options for HTML output --------------------------------------------------- 91 | 92 | # The theme to use for HTML and HTML Help pages. See the documentation for 93 | # a list of builtin themes. 94 | html_theme = 'default' 95 | 96 | # Theme options are theme-specific and customize the look and feel of a theme 97 | # further. For a list of options available for each theme, see the 98 | # documentation. 99 | #html_theme_options = {} 100 | 101 | # Add any paths that contain custom themes here, relative to this directory. 102 | #html_theme_path = [] 103 | 104 | # The name for this set of Sphinx documents. If None, it defaults to 105 | # " v documentation". 106 | #html_title = None 107 | 108 | # A shorter title for the navigation bar. Default is the same as html_title. 109 | #html_short_title = None 110 | 111 | # The name of an image file (relative to this directory) to place at the top 112 | # of the sidebar. 113 | #html_logo = None 114 | 115 | # The name of an image file (within the static path) to use as favicon of the 116 | # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 117 | # pixels large. 118 | #html_favicon = None 119 | 120 | # Add any paths that contain custom static files (such as style sheets) here, 121 | # relative to this directory. They are copied after the builtin static files, 122 | # so a file named "default.css" will overwrite the builtin "default.css". 123 | html_static_path = ['_static'] 124 | 125 | # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, 126 | # using the given strftime format. 127 | #html_last_updated_fmt = '%b %d, %Y' 128 | 129 | # If true, SmartyPants will be used to convert quotes and dashes to 130 | # typographically correct entities. 131 | #html_use_smartypants = True 132 | 133 | # Custom sidebar templates, maps document names to template names. 134 | #html_sidebars = {} 135 | 136 | # Additional templates that should be rendered to pages, maps page names to 137 | # template names. 138 | #html_additional_pages = {} 139 | 140 | # If false, no module index is generated. 141 | #html_domain_indices = True 142 | 143 | # If false, no index is generated. 144 | #html_use_index = True 145 | 146 | # If true, the index is split into individual pages for each letter. 147 | #html_split_index = False 148 | 149 | # If true, links to the reST sources are added to the pages. 150 | #html_show_sourcelink = True 151 | 152 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 153 | #html_show_sphinx = True 154 | 155 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 156 | #html_show_copyright = True 157 | 158 | # If true, an OpenSearch description file will be output, and all pages will 159 | # contain a tag referring to it. The value of this option must be the 160 | # base URL from which the finished HTML is served. 161 | #html_use_opensearch = '' 162 | 163 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 164 | #html_file_suffix = None 165 | 166 | # Output file base name for HTML help builder. 167 | htmlhelp_basename = 'python-songkickdoc' 168 | 169 | 170 | # -- Options for LaTeX output -------------------------------------------------- 171 | 172 | # The paper size ('letter' or 'a4'). 173 | #latex_paper_size = 'letter' 174 | 175 | # The font size ('10pt', '11pt' or '12pt'). 176 | #latex_font_size = '10pt' 177 | 178 | # Grouping the document tree into LaTeX files. List of tuples 179 | # (source start file, target name, title, author, documentclass [howto/manual]). 180 | latex_documents = [ 181 | ('index', 'python-songkick.tex', u'python-songkick Documentation', 182 | u'Matt Dennewitz', 'manual'), 183 | ] 184 | 185 | # The name of an image file (relative to this directory) to place at the top of 186 | # the title page. 187 | #latex_logo = None 188 | 189 | # For "manual" documents, if this is true, then toplevel headings are parts, 190 | # not chapters. 191 | #latex_use_parts = False 192 | 193 | # If true, show page references after internal links. 194 | #latex_show_pagerefs = False 195 | 196 | # If true, show URL addresses after external links. 197 | #latex_show_urls = False 198 | 199 | # Additional stuff for the LaTeX preamble. 200 | #latex_preamble = '' 201 | 202 | # Documents to append as an appendix to all manuals. 203 | #latex_appendices = [] 204 | 205 | # If false, no module index is generated. 206 | #latex_domain_indices = True 207 | 208 | 209 | # -- Options for manual page output -------------------------------------------- 210 | 211 | # One entry per manual page. List of tuples 212 | # (source start file, name, description, authors, manual section). 213 | man_pages = [ 214 | ('index', 'python-songkick', u'python-songkick Documentation', 215 | [u'Matt Dennewitz'], 1) 216 | ] 217 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. python-songkick documentation master file, created by 2 | sphinx-quickstart on Fri Nov 26 18:43:20 2010. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to python-songkick's documentation! 7 | =========================================== 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | Indices and tables 15 | ================== 16 | 17 | * :ref:`genindex` 18 | * :ref:`modindex` 19 | * :ref:`search` 20 | 21 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | if NOT "%PAPER%" == "" ( 11 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 12 | ) 13 | 14 | if "%1" == "" goto help 15 | 16 | if "%1" == "help" ( 17 | :help 18 | echo.Please use `make ^` where ^ is one of 19 | echo. html to make standalone HTML files 20 | echo. dirhtml to make HTML files named index.html in directories 21 | echo. singlehtml to make a single large HTML file 22 | echo. pickle to make pickle files 23 | echo. json to make JSON files 24 | echo. htmlhelp to make HTML files and a HTML help project 25 | echo. qthelp to make HTML files and a qthelp project 26 | echo. devhelp to make HTML files and a Devhelp project 27 | echo. epub to make an epub 28 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 29 | echo. text to make text files 30 | echo. man to make manual pages 31 | echo. changes to make an overview over all changed/added/deprecated items 32 | echo. linkcheck to check all external links for integrity 33 | echo. doctest to run all doctests embedded in the documentation if enabled 34 | goto end 35 | ) 36 | 37 | if "%1" == "clean" ( 38 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 39 | del /q /s %BUILDDIR%\* 40 | goto end 41 | ) 42 | 43 | if "%1" == "html" ( 44 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 45 | if errorlevel 1 exit /b 1 46 | echo. 47 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 48 | goto end 49 | ) 50 | 51 | if "%1" == "dirhtml" ( 52 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 53 | if errorlevel 1 exit /b 1 54 | echo. 55 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 56 | goto end 57 | ) 58 | 59 | if "%1" == "singlehtml" ( 60 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 61 | if errorlevel 1 exit /b 1 62 | echo. 63 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 64 | goto end 65 | ) 66 | 67 | if "%1" == "pickle" ( 68 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 69 | if errorlevel 1 exit /b 1 70 | echo. 71 | echo.Build finished; now you can process the pickle files. 72 | goto end 73 | ) 74 | 75 | if "%1" == "json" ( 76 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 77 | if errorlevel 1 exit /b 1 78 | echo. 79 | echo.Build finished; now you can process the JSON files. 80 | goto end 81 | ) 82 | 83 | if "%1" == "htmlhelp" ( 84 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 85 | if errorlevel 1 exit /b 1 86 | echo. 87 | echo.Build finished; now you can run HTML Help Workshop with the ^ 88 | .hhp project file in %BUILDDIR%/htmlhelp. 89 | goto end 90 | ) 91 | 92 | if "%1" == "qthelp" ( 93 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 94 | if errorlevel 1 exit /b 1 95 | echo. 96 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 97 | .qhcp project file in %BUILDDIR%/qthelp, like this: 98 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\python-songkick.qhcp 99 | echo.To view the help file: 100 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\python-songkick.ghc 101 | goto end 102 | ) 103 | 104 | if "%1" == "devhelp" ( 105 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 106 | if errorlevel 1 exit /b 1 107 | echo. 108 | echo.Build finished. 109 | goto end 110 | ) 111 | 112 | if "%1" == "epub" ( 113 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 114 | if errorlevel 1 exit /b 1 115 | echo. 116 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 117 | goto end 118 | ) 119 | 120 | if "%1" == "latex" ( 121 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 122 | if errorlevel 1 exit /b 1 123 | echo. 124 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 125 | goto end 126 | ) 127 | 128 | if "%1" == "text" ( 129 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 130 | if errorlevel 1 exit /b 1 131 | echo. 132 | echo.Build finished. The text files are in %BUILDDIR%/text. 133 | goto end 134 | ) 135 | 136 | if "%1" == "man" ( 137 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 138 | if errorlevel 1 exit /b 1 139 | echo. 140 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 141 | goto end 142 | ) 143 | 144 | if "%1" == "changes" ( 145 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 146 | if errorlevel 1 exit /b 1 147 | echo. 148 | echo.The overview file is in %BUILDDIR%/changes. 149 | goto end 150 | ) 151 | 152 | if "%1" == "linkcheck" ( 153 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 154 | if errorlevel 1 exit /b 1 155 | echo. 156 | echo.Link check complete; look for any errors in the above output ^ 157 | or in %BUILDDIR%/linkcheck/output.txt. 158 | goto end 159 | ) 160 | 161 | if "%1" == "doctest" ( 162 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 163 | if errorlevel 1 exit /b 1 164 | echo. 165 | echo.Testing of doctests in the sources finished, look at the ^ 166 | results in %BUILDDIR%/doctest/output.txt. 167 | goto end 168 | ) 169 | 170 | :end 171 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx 2 | httplib2 3 | python-dateutil 4 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import codecs 2 | import os 3 | import re 4 | from setuptools import setup, find_packages 5 | 6 | 7 | def read(*parts): 8 | return codecs.open(os.path.join(os.path.dirname(__file__), *parts)).read() 9 | 10 | 11 | def find_version(*file_paths): 12 | version_file = read(*file_paths) 13 | version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", 14 | version_file, re.M) 15 | if version_match: 16 | return version_match.group(1) 17 | raise RuntimeError("Unable to find version string.") 18 | 19 | 20 | setup( 21 | name='python-songkick', 22 | version=find_version('songkick', '__init__.py'), 23 | description='Songkick API wrapper', 24 | long_description=read('README.rst'), 25 | author='Matt Dennewitz', 26 | author_email='mattdennewitz@gmail.com', 27 | url='http://github.com/mattdennewitz/python-songkick/tree/master', 28 | packages=find_packages(), 29 | classifiers=[ 30 | 'Development Status :: 3 - Alpha', 31 | 'Environment :: Web Environment', 32 | 'Intended Audience :: Developers', 33 | 'License :: OSI Approved :: BSD License', 34 | 'Operating System :: OS Independent', 35 | 'Programming Language :: Python' 36 | ], 37 | install_requires=['httplib2>=0.7.4'], 38 | ) 39 | -------------------------------------------------------------------------------- /songkick/__init__.py: -------------------------------------------------------------------------------- 1 | from connection import SongkickConnection as Songkick 2 | 3 | 4 | __author__ = 'Matt Dennewitz' 5 | __version__ = '0.0.1' 6 | __version_info__ = tuple(__version__.split('.')) 7 | 8 | 9 | __all__ = ['Songkick'] 10 | 11 | 12 | def get_version(): 13 | return __version__ 14 | -------------------------------------------------------------------------------- /songkick/base.py: -------------------------------------------------------------------------------- 1 | class SongkickModelOptions(object): 2 | fields = None 3 | 4 | def __new__(cls, meta=None): 5 | overrides = {} 6 | if meta is not None: 7 | for key, value in meta.iteritems(): 8 | if key.startswith('_'): 9 | continue 10 | overrides[key] = value 11 | return object.__new__(type('SongkickModelOptions', 12 | (cls, ), 13 | overrides)) 14 | 15 | 16 | class SongkickModelMetaclass(type): 17 | 18 | def __new__(cls, name, bases, attrs): 19 | 20 | new_cls = super(SongkickModelMetaclass, cls).__new__(cls, name, 21 | bases, attrs) 22 | if '__metaclass__' in attrs: 23 | return new_cls 24 | 25 | opts = getattr(new_cls, 'Meta', None) 26 | new_cls._meta = SongkickModelOptions(opts) 27 | 28 | fields = {} 29 | 30 | for key, value in attrs.iteritems(): 31 | if isinstance(value, BaseField): 32 | value.field_name = key 33 | if value.mapping is None: 34 | value.mapping = key 35 | fields[key] = value 36 | 37 | new_cls._fields = fields 38 | 39 | return new_cls 40 | 41 | 42 | class SongkickModel(object): 43 | __metaclass__ = SongkickModelMetaclass 44 | 45 | def __init__(self, **values): 46 | self._data = {} 47 | 48 | for field_name in self._fields.keys(): 49 | try: 50 | setattr(self, field_name, values.pop(field_name)) 51 | except AttributeError: 52 | pass 53 | 54 | @classmethod 55 | def _from_json(cls, data): 56 | """Build an instance of ``cls`` using ``data``. 57 | """ 58 | 59 | values = {} 60 | 61 | for field_name, field in cls._fields.items(): 62 | 63 | # start with nothing 64 | value = None 65 | 66 | if '__' in field.mapping: 67 | bits = field.mapping.split('__') 68 | first_bit = bits.pop(0) 69 | value = data[first_bit] 70 | 71 | while bits: 72 | bit = bits.pop(0) 73 | value = value.get(bit) 74 | else: 75 | value = data.get(field.mapping) 76 | 77 | if value is not None: 78 | value = field.to_python(value) 79 | 80 | # finally, set the value 81 | values[field_name] = value 82 | 83 | return cls(**values) 84 | 85 | 86 | class BaseField(object): 87 | 88 | def __init__(self, field_name=None, mapping=None, default=None): 89 | """Set up a Songkick field responsible for storing 90 | and translating JSON data into something useful. 91 | """ 92 | 93 | self.field_name = field_name 94 | self.mapping = mapping or field_name 95 | self.default = default 96 | 97 | def __get__(self, instance, owner): 98 | value = instance._data.get(self.field_name) 99 | if value is None: 100 | # try a default 101 | return self.default 102 | return value 103 | 104 | def __set__(self, instance, value): 105 | instance._data[self.field_name] = value 106 | -------------------------------------------------------------------------------- /songkick/connection.py: -------------------------------------------------------------------------------- 1 | import urllib 2 | import urlparse 3 | 4 | import httplib2 5 | 6 | from songkick.events.query import EventQuery, GigographyQuery 7 | from songkick.exceptions import SongkickRequestError 8 | from songkick.setlists.query import SetlistQuery 9 | 10 | 11 | class SongkickConnection(object): 12 | 13 | ApiBase = 'http://api.songkick.com/api/3.0/' 14 | 15 | def __init__(self, api_key): 16 | self.api_key = api_key 17 | self._http = httplib2.Http('.songkick_cache') 18 | 19 | def make_request(self, url, method='GET', body=None, headers=None): 20 | """Make an HTTP request. 21 | 22 | This could stand to be a little more robust, but Songkick's API 23 | is very straight-forward: 200 is a success, anything else is wrong. 24 | """ 25 | 26 | headers = headers or {} 27 | headers['Accept-Charset'] = 'utf-8' 28 | 29 | response, content = self._http.request(url, method, body, headers) 30 | 31 | if int(response.status) != 200: 32 | raise SongkickRequestError('Could not load %s: [%s] %s' % \ 33 | (url, response.status, 34 | response.reason)) 35 | return content 36 | 37 | def build_songkick_url(self, api_path, request_args): 38 | "Assemble the Songkick URL" 39 | 40 | # insert API key 41 | request_args['apikey'] = self.api_key 42 | 43 | # construct the complete api resource url, minus args 44 | url = urlparse.urljoin(SongkickConnection.ApiBase, api_path) 45 | 46 | # break down the url into its components, inject args 47 | # as query string and recombine the url 48 | url_parts = list(urlparse.urlparse(url)) 49 | url_parts[4] = urllib.urlencode(request_args) 50 | url = urlparse.urlunparse(url_parts) 51 | 52 | return url 53 | 54 | @property 55 | def events(self): 56 | return EventQuery(self) 57 | 58 | @property 59 | def gigography(self): 60 | return GigographyQuery(self) 61 | 62 | @property 63 | def setlists(self): 64 | return SetlistQuery(self) 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /songkick/events/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdennewitz/python-songkick/b5557966e2a543cbd1c17628a78a8fa74a1ad16d/songkick/events/__init__.py -------------------------------------------------------------------------------- /songkick/events/models.py: -------------------------------------------------------------------------------- 1 | from songkick.base import SongkickModel 2 | from songkick import fields 3 | 4 | 5 | class SongkickArtistIdentifier(SongkickModel): 6 | """Universal artist identification. 7 | 8 | :param data_uri: Songkick data outlet URI 9 | :param musicbrainz_id: A possible MusicBrainz id for this artist 10 | 11 | .. note:: Songkick stores multiple identifiers for artists 12 | with non-unique names. For example, Songkick stores 13 | seven possible MusicBrainz ids for the swedish pop duo 14 | "jj", because there are at least seven acts releasing 15 | under that name. It's up to the client to store 16 | and match the correct MusicBrainz id. 17 | """ 18 | 19 | data_uri = fields.Field(mapping='href') 20 | musicbrainz_id = fields.Field(mapping='mbid') 21 | 22 | 23 | class SongkickArtist(SongkickModel): 24 | """A Songkick-described artist. 25 | 26 | :param id: Songkick id 27 | :param display_name: Artist name, eg, "Neil Young". 28 | :param songkick_uri: Songkick artist detail uri 29 | :param identifiers: A list of :class:`SongkickArtistIdentifier` objects 30 | :param billing: Event billing status. 'headline' or 'support'. 31 | :param billing_index: Numerical position on the bill 32 | """ 33 | 34 | id = fields.Field() 35 | display_name = fields.Field(mapping='displayName') 36 | songkick_uri = fields.Field(mapping='artist__uri') 37 | identifiers = fields.ListField(fields.ObjectField(SongkickArtistIdentifier), 38 | mapping='artist__identifier') 39 | billing = fields.Field() 40 | billing_index = fields.Field(mapping='billingIndex') 41 | 42 | def __repr__(self): 43 | return self.display_name.encode('utf-8') 44 | 45 | 46 | class SongkickEventDate(SongkickModel): 47 | """Known times for an event. Used to detail the start 48 | and, when available, end of a certain event. 49 | 50 | :param date: ``date`` object representing event date. Normally available. 51 | :param time: ``time`` object representing event time. Sometimes available. 52 | :param datetime: ``datetime`` object with timezone info. Sometimes available. 53 | """ 54 | 55 | date = fields.DateField() 56 | time = fields.TimeField() 57 | datetime = fields.DateTimeField() 58 | 59 | 60 | class SongkickLocation(SongkickModel): 61 | """Overview of show location, not including venue details. 62 | 63 | :param city: City name. Often sent as City, State, Country, 64 | but no particular format is enforced. 65 | :param latitude: Latitude 66 | :param longitude: Longitude 67 | """ 68 | 69 | city = fields.Field() 70 | latitude = fields.Field(mapping='lat') 71 | longitude = fields.Field(mapping='lng') 72 | 73 | 74 | class SongkickMetroArea(SongkickModel): 75 | """A metro area, used to describe where a :class:`SongkickVenue` 76 | is located. 77 | 78 | :param id: Songkick id 79 | :param display_name: Metro area name 80 | :param country: Country name 81 | """ 82 | 83 | id = fields.Field() 84 | display_name = fields.Field(mapping='displayName') 85 | country = fields.Field(mapping='country__displayName') 86 | 87 | 88 | class SongkickVenue(SongkickModel): 89 | """Event venue. 90 | 91 | :param id: Songkick id 92 | :param display_name: Venue name 93 | :param latitude: Venue latitude 94 | :param longitude: Venue longitude 95 | :param metro_area: The :class:`SongkickMetroArea` describing this 96 | venue's location 97 | :param uri: Songkick venue data uri 98 | """ 99 | 100 | id = fields.Field() 101 | display_name = fields.Field(mapping='displayName') 102 | latitude = fields.Field(mapping='lat') 103 | longitude = fields.Field(mapping='lng') 104 | metro_area = fields.ObjectField(SongkickMetroArea, 105 | mapping='metroArea') 106 | uri = fields.Field() 107 | 108 | def __repr__(self): 109 | return self.display_name.encode('utf-8') 110 | 111 | 112 | class SongkickEventSeries(SongkickModel): 113 | """Serial show wrapper name. Useful for describing long-running 114 | events, like festivals. 115 | 116 | :param display_name: Series name 117 | """ 118 | 119 | display_name = fields.Field(mapping='displayName') 120 | 121 | 122 | class SongkickEvent(SongkickModel): 123 | """An event tracked by Songkick. 124 | 125 | :param id: Songkick id 126 | :param status: Event status. Normally 'ok', sometimes 'cancelled'. 127 | :param event_type: Event type. 'concert' or 'festival'. 128 | :param venue: :class:`SongkickVenue` object 129 | :param location: :class:`SongkickLocation` object 130 | :param artists: Collection of artists (via :class:`SongkickArtist`) 131 | performing at this event. 132 | :param display_name: Event title 133 | :param popularity: Popularity measurement for this event 134 | :param event_start: Start date and (sometimes) time for this event 135 | :param event_end: End date and (sometimes) time for this event. 136 | Not often populated, and normally only seen 137 | with festivals. 138 | :param uri: Songkick data uri 139 | """ 140 | 141 | id = fields.Field() 142 | status = fields.Field() 143 | event_type = fields.Field(mapping='type') 144 | series = fields.ObjectField(SongkickEventSeries) 145 | venue = fields.ObjectField(SongkickVenue) 146 | location = fields.ObjectField(SongkickLocation) 147 | artists = fields.ListField(fields.ObjectField(SongkickArtist), 148 | mapping='performance') 149 | display_name = fields.Field(mapping='displayName') 150 | popularity = fields.DecimalField() 151 | event_start = fields.ObjectField(SongkickEventDate, mapping='start') 152 | event_end = fields.ObjectField(SongkickEventDate, mapping='end') 153 | uri = fields.Field() 154 | 155 | def __repr__(self): 156 | return self.display_name.encode('utf-8') 157 | 158 | def is_active(self): 159 | return bool(self.status == 'ok') 160 | 161 | -------------------------------------------------------------------------------- /songkick/events/query.py: -------------------------------------------------------------------------------- 1 | from songkick.events.models import SongkickEvent 2 | from songkick.query import SongkickQuery 3 | 4 | 5 | class EventQuery(SongkickQuery): 6 | "Events-specific query backend" 7 | 8 | ResponseClass = SongkickEvent 9 | ResponseEnclosure = 'event' 10 | 11 | def get_api_path(self): 12 | "Generate the API resource path" 13 | 14 | if 'musicbrainz_id' in self._query: 15 | return 'artists/mbid:%s/events.json' % \ 16 | self._query.pop('musicbrainz_id') 17 | return 'events.json' 18 | 19 | class GigographyQuery(EventQuery): 20 | "Gigography-specific query backend" 21 | 22 | ResponseClass = SongkickEvent 23 | ResponseEnclosure = 'event' 24 | 25 | def get_api_path(self): 26 | "Generate the API resource path" 27 | 28 | if 'musicbrainz_id' in self._query: 29 | return 'artists/mbid:%s/gigography.json' % \ 30 | self._query.pop('musicbrainz_id') 31 | return 'artists/%s/gigography.json' % \ 32 | self._query.pop('artist_id') -------------------------------------------------------------------------------- /songkick/exceptions.py: -------------------------------------------------------------------------------- 1 | class SongkickRequestError(Exception): 2 | pass 3 | 4 | 5 | class SongkickDecodeError(Exception): 6 | pass 7 | -------------------------------------------------------------------------------- /songkick/fields.py: -------------------------------------------------------------------------------- 1 | from datetime import date 2 | from decimal import Decimal 3 | from time import strptime 4 | 5 | from dateutil.parser import parse as dateutil_parse 6 | 7 | from songkick.base import BaseField 8 | 9 | 10 | class Field(BaseField): 11 | 12 | def to_python(self, value): 13 | return value 14 | 15 | 16 | class StringField(BaseField): 17 | 18 | def to_python(self, value): 19 | if not isinstance(value, basestring): 20 | value = str(value) 21 | return value.encode('utf-8') 22 | 23 | 24 | class BooleanField(Field): 25 | 26 | def to_python(self, value): 27 | return bool(value) 28 | 29 | 30 | class IntField(Field): 31 | 32 | def to_python(self, value): 33 | if not isinstance(value, int): 34 | value = int(value) 35 | return value 36 | 37 | class DecimalField(Field): 38 | 39 | def to_python(self, value): 40 | if not isinstance(value, Decimal): 41 | value = Decimal(str(value)) 42 | return value 43 | 44 | 45 | class DateField(Field): 46 | 47 | def to_python(self, value): 48 | return date(*strptime(value, '%Y-%m-%d')[:3]) 49 | 50 | 51 | class DateTimeField(Field): 52 | 53 | def to_python(self, value): 54 | return dateutil_parse(value) 55 | 56 | 57 | class TimeField(Field): 58 | 59 | def to_python(self, value): 60 | return strptime(value, '%H:%M:%S') 61 | 62 | 63 | class ObjectField(Field): 64 | 65 | def __init__(self, object_class, **kwargs): 66 | self.cls = object_class 67 | super(ObjectField, self).__init__(**kwargs) 68 | 69 | def to_python(self, value): 70 | return self.cls._from_json(value) 71 | 72 | 73 | class ListField(Field): 74 | 75 | def __init__(self, field=None, **kwargs): 76 | self.field = field 77 | kwargs['default'] = [] 78 | super(ListField, self).__init__(**kwargs) 79 | 80 | def to_python(self, value): 81 | if self.field is not None: 82 | return [self.field.to_python(v) for v in value] 83 | return value 84 | 85 | -------------------------------------------------------------------------------- /songkick/query.py: -------------------------------------------------------------------------------- 1 | import json 2 | from math import ceil 3 | 4 | from songkick.exceptions import SongkickDecodeError 5 | 6 | 7 | class SongkickQuery(object): 8 | 9 | def __init__(self, connection): 10 | self._query = {} 11 | self._result_cache = None 12 | self._connection = connection 13 | 14 | @classmethod 15 | def parse_songkick_data(cls, event_data): 16 | "Parse event data, return ``SongkickResultPage``." 17 | 18 | try: 19 | data = json.loads(event_data) 20 | except Exception, exc: 21 | msg = "Couldn't decode response: %s" % exc 22 | raise SongkickDecodeError(msg) 23 | 24 | # parse results 25 | page = data['resultsPage'] 26 | results_wrapper = page.get('results') 27 | 28 | if not cls.ResponseEnclosure in results_wrapper: 29 | raise SongkickDecodeError("%s not found in results page." % \ 30 | cls.ResponseEnclosure) 31 | 32 | # pull objects from response 33 | object_list = results_wrapper.get(cls.ResponseEnclosure) 34 | 35 | for obj in object_list: 36 | yield cls.ResponseClass._from_json(obj) 37 | 38 | def get_api_path(self): 39 | raise NotImplementedError 40 | 41 | def query(self, **query_kwargs): 42 | """Query Songkick, load results, return data page. 43 | 44 | :param **query_kwargs: All keyword arguments to be converted 45 | into a Songkick request. 46 | :rtype: :class:`SongkickResultPage` containing pagination data 47 | and results 48 | """ 49 | 50 | # update query args 51 | self._query = query_kwargs 52 | 53 | # generate songkick url 54 | url = self._connection.build_songkick_url(self.get_api_path(), 55 | self._query) 56 | 57 | # request event data 58 | sk_data = self._connection.make_request(url) 59 | 60 | # parse response 61 | return self.parse_songkick_data(sk_data) 62 | 63 | -------------------------------------------------------------------------------- /songkick/setlists/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mattdennewitz/python-songkick/b5557966e2a543cbd1c17628a78a8fa74a1ad16d/songkick/setlists/__init__.py -------------------------------------------------------------------------------- /songkick/setlists/models.py: -------------------------------------------------------------------------------- 1 | from songkick.base import SongkickModel 2 | from songkick.events.models import SongkickArtistIdentifier 3 | from songkick import fields 4 | 5 | 6 | class SongkickSetlistItem(SongkickModel): 7 | """A setlist entry. 8 | 9 | :param song_title: Title of the song or piece 10 | :param encore: Boolean value stating if this was part of an encore 11 | """ 12 | 13 | title = fields.Field(mapping='name') 14 | encore = fields.BooleanField() 15 | 16 | 17 | class SongkickSetlistArtist(SongkickModel): 18 | """Setlist artist summary. 19 | 20 | :param id: Songkick artist id 21 | :param display_name: Artist's name 22 | :param songkick_uri: Songkick artist detail uri 23 | :param identifiers: A list of :ref:`SongkickArtistIdentifier` objects 24 | 25 | .. note:: Artist representations are not consistent between resources, 26 | so we have to redefine a simpler artist model for setlists. 27 | """ 28 | 29 | id = fields.Field() 30 | display_name = fields.Field(mapping='displayName') 31 | songkick_uri = fields.Field(mapping='uri') 32 | identifiers = fields.ListField(fields.ObjectField(SongkickArtistIdentifier)) 33 | 34 | 35 | class SongkickSetlist(SongkickModel): 36 | """An event's setlist. 37 | 38 | :param id: Songkick setlist id 39 | :param display_name: Setlist name 40 | :param artist: :class:`SongkickSetlistArtist` object representing the 41 | performing artist 42 | :param setlist: Songs or pieces performed in this set, as a list of 43 | :class:`SongkickSetlistItem` objects. 44 | """ 45 | 46 | id = fields.Field() 47 | display_name = fields.Field(mapping='displayName') 48 | artist = fields.ObjectField(SongkickSetlistArtist) 49 | setlist_items = fields.ListField(fields.ObjectField(SongkickSetlistItem), 50 | mapping='setlistItem') 51 | 52 | def __repr__(self): 53 | return self.display_name.encode('utf-8') 54 | 55 | -------------------------------------------------------------------------------- /songkick/setlists/query.py: -------------------------------------------------------------------------------- 1 | from songkick.query import SongkickQuery 2 | from songkick.setlists.models import SongkickSetlist 3 | 4 | 5 | class SetlistQuery(SongkickQuery): 6 | 7 | ResponseClass = SongkickSetlist 8 | ResponseEnclosure = 'setlist' 9 | 10 | def get_api_path(self): 11 | "Generate the API resource path" 12 | 13 | return 'events/%s/setlists.json' % self._query.pop('event_id') 14 | 15 | def get(self, id): 16 | """Return a setlist with the given ``id``. 17 | 18 | This method is a bit of a hack, but Songkick's setlist API only 19 | responds to ids. There is no need to return an iterable. 20 | """ 21 | 22 | results = self.query(event_id=id) 23 | if len(results) > 0: 24 | return results[0] 25 | 26 | -------------------------------------------------------------------------------- /songkick/utils.py: -------------------------------------------------------------------------------- 1 | class ConstantMap(dict): 2 | 3 | def __getattr__(self, key): 4 | return self.get(key, None) 5 | __setattr__ = dict.__setattr__ 6 | __delattr__ = dict.__delattr__ 7 | --------------------------------------------------------------------------------