Class Amazon

    • Constructor Detail

      • Amazon

        public Amazon()
        No arg constructor. Defaults to system locale.
    • Method Detail

      • getName

        public String getName()
        Description copied from interface: Charts
        Name of this chart provider.
        Specified by:
        getName in interface Charts
        Returns:
        chart provider name
      • getCharts

        public List<PlayList> getCharts​(Locale market)
        Description copied from interface: Charts
        Fetch charts in the form of PlayLists for the given Locale. These lists may be specific to genre or other properties.
        Specified by:
        getCharts in interface Charts
        Parameters:
        market - locale market to use for lookup, if the implementation supports localization
        Returns:
        list of charts
      • toItems

        public static Stream<org.json.simple.JSONObject> toItems​(org.json.simple.JSONObject itemSearchResponse)
      • addPropertyChangeListener

        public void addPropertyChangeListener​(String propertyName,
                                              PropertyChangeListener propertyChangeListener)
        Add property change listener.
        Parameters:
        propertyName - property name
        propertyChangeListener - listener
      • removePropertyChangeListener

        public void removePropertyChangeListener​(String propertyName,
                                                 PropertyChangeListener propertyChangeListener)
        Remove property change listener.
        Parameters:
        propertyName - property name
        propertyChangeListener - listener
      • getLocale

        public Locale getLocale()
      • browseNodeLookup

        public org.json.simple.JSONObject browseNodeLookup​(BrowseNode browseNode,
                                                           long maximumAge,
                                                           TimeUnit timeUnit)
                                                    throws IOException,
                                                           org.json.simple.parser.ParseException
        Looks up browsenode.
        Parameters:
        browseNode - browsenode
        maximumAge - max age
        timeUnit - max age time unit
        Returns:
        response
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • browseNodeLookup

        public org.json.simple.JSONObject browseNodeLookup​(long browseNodeId,
                                                           long maximumAge,
                                                           TimeUnit timeUnit)
                                                    throws IOException,
                                                           org.json.simple.parser.ParseException
        Looks up browsenode.
        Parameters:
        browseNodeId - browsenode id
        maximumAge - max age
        timeUnit - max age time unit
        Returns:
        response
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • getGenreBrowseNodes

        public List<org.json.simple.JSONObject> getGenreBrowseNodes()
                                                             throws IOException,
                                                                    org.json.simple.parser.ParseException
        Get the genre browse nodes for the currently configured locale.
        Returns:
        list of genres
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • writeGenreBrowseNodes

        public void writeGenreBrowseNodes​(Path path)
                                   throws IOException,
                                          org.json.simple.parser.ParseException
        Dump genre browse nodes to a file.
        Parameters:
        path - file
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • writeGenreBrowseNodes

        public void writeGenreBrowseNodes()
                                   throws IOException,
                                          org.json.simple.parser.ParseException
        Dump genre browse nodes to a file called "browsenode_[locale].txt".
        Throws:
        IOException
        javax.xml.bind.DataBindingException
        org.json.simple.parser.ParseException
      • itemSearch

        public org.json.simple.JSONObject itemSearch​(String keywords)
                                              throws IOException,
                                                     org.json.simple.parser.ParseException
        Searches in SearchIndex Music for items which match the given keywords.
        Parameters:
        keywords - String that contains keywords
        Returns:
        search result
        Throws:
        IOException
        javax.xml.bind.DataBindingException
        org.json.simple.parser.ParseException
      • itemSearch

        public org.json.simple.JSONObject itemSearch​(String searchIndex,
                                                     String keywords)
                                              throws IOException,
                                                     org.json.simple.parser.ParseException
        Searches in a given SearchIndex for items which match the given keywords. Sorted by "Relevance".
        Parameters:
        searchIndex - search index like "Music" or "MP3Downloads"
        keywords - String that contains keywords
        Returns:
        search result
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • itemSearch

        public org.json.simple.JSONObject itemSearch​(String searchIndex,
                                                     BrowseNode browseNode,
                                                     String keywords,
                                                     String sortBy,
                                                     int page,
                                                     long maximumAge,
                                                     TimeUnit timeUnit)
                                              throws IOException,
                                                     org.json.simple.parser.ParseException
        Searches in a given SearchIndex for items which match the given keywords.
        Parameters:
        searchIndex - search index like "Music" or "MP3Downloads"
        browseNode - browse node (may be null)
        keywords - String that contains keywords
        sortBy - e.g. "Relevance" or "NewestArrivals" (docs)
        page - page, use -1, if you don't want to specify
        Returns:
        search result
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • itemSearchTopSellers

        public org.json.simple.JSONObject itemSearchTopSellers​(BrowseNode browseNode,
                                                               int page)
                                                        throws IOException,
                                                               org.json.simple.parser.ParseException
        ItemSearch in a Music search index, result ordered by relevance.
        Parameters:
        browseNode - browsenode in which to search
        page - result page to return
        Returns:
        result
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • itemSearchTopSellers

        public org.json.simple.JSONObject itemSearchTopSellers​(String searchIndex,
                                                               BrowseNode browseNode,
                                                               int page)
                                                        throws IOException,
                                                               org.json.simple.parser.ParseException
        ItemSearch result, ordered by relevance (whatever that is).
        Parameters:
        searchIndex - usually "Music", but values like "MP3Downloads" should also be possible (for the US at least).
        browseNode - browsenode in which to search
        page - result page to return
        Returns:
        result
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • itemSearchNewReleases

        public org.json.simple.JSONObject itemSearchNewReleases​(BrowseNode browseNode,
                                                                int page)
                                                         throws IOException,
                                                                org.json.simple.parser.ParseException
        ItemSearch in a Music search index, result ordered by age.
        Parameters:
        browseNode - browsenode in which to search
        page - result page to return
        Returns:
        result
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • itemSearchNewReleases

        public org.json.simple.JSONObject itemSearchNewReleases​(String searchIndex,
                                                                BrowseNode browseNode,
                                                                int page)
                                                         throws IOException,
                                                                org.json.simple.parser.ParseException
        ItemSearch result, ordered by age.
        Parameters:
        searchIndex - usually "Music", but values like "MP3Downloads" should also be possible (for the US at least).
        browseNode - browsenode in which to search
        page - result page to return
        Returns:
        result
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • getMusicAlbum

        public org.json.simple.JSONObject getMusicAlbum​(String artist,
                                                        String title)
                                                 throws IOException,
                                                        org.json.simple.parser.ParseException
        ItemSearch for Music matching an encodedArtist/encodedTitle.
        Parameters:
        artist - encodedArtist or null, if not significant
        title - encodedTitle or null, if not significant
        Returns:
        matching articles
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • getMP3DownloadsAlbum

        public org.json.simple.JSONObject getMP3DownloadsAlbum​(String artist,
                                                               String title)
                                                        throws IOException,
                                                               org.json.simple.parser.ParseException
        ItemSearch for MP3Downloads matching an encodedArtist/encodedTitle.
        Parameters:
        artist - encodedArtist or null, if not significant
        title - encodedTitle or null, if not significant
        Returns:
        matching articles
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • getTitle

        public org.json.simple.JSONObject getTitle​(String searchIndex,
                                                   String title)
                                            throws IOException,
                                                   org.json.simple.parser.ParseException
        ItemSearch for an item with the specified title.
        Parameters:
        searchIndex - index to search
        title - encodedTitle
        Returns:
        matching articles
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • itemLookup

        public org.json.simple.JSONObject itemLookup​(String... asin)
                                              throws IOException,
                                                     org.json.simple.parser.ParseException
        Look up an item using it's ASIN.
        Parameters:
        asin - an ASIN
        Returns:
        response
        Throws:
        IOException
        javax.xml.bind.DataBindingException
        org.json.simple.parser.ParseException
      • getJSONObject

        protected org.json.simple.JSONObject getJSONObject​(String request,
                                                           org.json.simple.JSONObject requestPayload)
                                                    throws IOException,
                                                           org.json.simple.parser.ParseException
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • getJSONObject

        protected org.json.simple.JSONObject getJSONObject​(String request,
                                                           org.json.simple.JSONObject requestPayload,
                                                           long maximumAge,
                                                           TimeUnit timeUnit)
                                                    throws IOException,
                                                           org.json.simple.parser.ParseException
        Throws:
        IOException
        org.json.simple.parser.ParseException
      • cacheResource

        protected boolean cacheResource​(URL url,
                                        byte[] content)
        Description copied from class: WebService
        Allows turning caching for a specific resource and its content on and off.
        Overrides:
        cacheResource in class WebService
        Parameters:
        url - url
        content - resource content
        Returns:
        by default this method returns true
      • useCacheOnly

        protected boolean useCacheOnly​(URL url)
        Description copied from class: WebService
        Allows to suppress the actual request.
        Overrides:
        useCacheOnly in class WebService
        Parameters:
        url - url
        Returns:
        true, if we only want to look stuff up in the cache, but never want to retrieve the actual URL