This file is indexed.

/usr/share/pyshared/mygpoclient/public.py is in python-mygpoclient 1.7-1.

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
# -*- coding: utf-8 -*-
# gpodder.net API Client
# Copyright (C) 2009-2013 Thomas Perl and the gPodder Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import mygpoclient

from mygpoclient import locator
from mygpoclient import json
from mygpoclient import simple

class Tag(object):
    """Container class for a tag in the top tag list

    Attributes:
    tag - The name of the tag
    usage - Usage of the tag
    """

    REQUIRED_KEYS = ('tag', 'usage')

    def __init__(self, tag, usage):
        self.tag = tag
        self.usage = usage

    @classmethod
    def from_dict(cls, d):
        for key in cls.REQUIRED_KEYS:
            if key not in d:
                raise ValueError('Missing keys for tag')

        return cls(*(d.get(k) for k in cls.REQUIRED_KEYS))

    def __eq__(self, other):
        """Test two tag objects for equality

        >>> Tag('u', 123) == Tag('u', 123)
        True
        >>> Tag('u', 123) == Tag('a', 345)
        False
        >>> Tag('u', 123) == 'x'
        False
        """
        if not isinstance(other, self.__class__):
            return False

        return all(getattr(self, k) == getattr(other, k) \
                for k in self.REQUIRED_KEYS)

        

class Episode(object):
    """Container Class for Episodes
    
    Attributes:
    title -
    url -
    podcast_title -
    podcast_url -
    description -
    website -
    released -
    mygpo_link -
    """
    
    REQUIRED_KEYS = ('title', 'url', 'podcast_title', 'podcast_url',
                     'description', 'website', 'released', 'mygpo_link')
    
    def __init__(self, title, url, podcast_title, podcast_url, description, website, released, mygpo_link):
        self.title = title
        self.url = url
        self.podcast_title = podcast_title
        self.podcast_url = podcast_url
        self.description = description
        self.website = website
        self.released = released
        self.mygpo_link = mygpo_link
        
    @classmethod
    def from_dict(cls, d):
        for key in cls.REQUIRED_KEYS:
            if key not in d:
                raise ValueError('Missing keys for episode')
            
        return cls(*(d.get(k) for k in cls.REQUIRED_KEYS))
        
    def __eq__(self, other):
        """Test two Episode objects for equality
            
        >>> Episode('a','b','c','d','e','f','g','h') == Episode('a','b','c','d','e','f','g','h')
        True
        >>> Episode('a','b','c','d','e','f','g','h') == Episode('s','t','u','v','w','x','y','z')
        False
        >>> Episode('a','b','c','d','e','f','g','h') == 'x'
        False
        """
        if not isinstance(other, self.__class__):
            return False

        return all(getattr(self, k) == getattr(other, k) \
            for k in self.REQUIRED_KEYS)
                
class PublicClient(object):
    """Client for the gpodder.net "anonymous" API

    This is the API client implementation that provides a
    pythonic interface to the parts of the gpodder.net
    Simple API that don't need user authentication.
    """
    FORMAT = 'json'

    def __init__(self, host=mygpoclient.HOST, client_class=json.JsonClient):
        """Creates a new Public API client

        The parameter host is optional and defaults to
        the main webservice.

        The parameter client_class is optional and should
        not need to be changed in normal use cases. If it
        is changed, it should provide the same interface
        as the json.JsonClient class in mygpoclient.
        """
        self._locator = locator.Locator(None, host)
        self._client = client_class(None, None)

    def get_toplist(self, count=mygpoclient.TOPLIST_DEFAULT):
        """Get a list of most-subscribed podcasts

        Returns a list of simple.Podcast objects.

        The parameter "count" is optional and describes
        the amount of podcasts that are returned. The
        default value is 50, the minimum value is 1 and
        the maximum value is 100.
        """
        uri = self._locator.toplist_uri(count, self.FORMAT)
        return [simple.Podcast.from_dict(x) for x in self._client.GET(uri)]

    def search_podcasts(self, query):
        """Search for podcasts on the webservice

        Returns a list of simple.Podcast objects.

        The parameter "query" specifies the search
        query as a string.
        """
        uri = self._locator.search_uri(query, self.FORMAT)
        return [simple.Podcast.from_dict(x) for x in self._client.GET(uri)]

    def get_podcasts_of_a_tag(self, tag, count=mygpoclient.TOPLIST_DEFAULT):
        """Get a list of most-subscribed podcasts of a Tag

        Returns a list of simple.Podcast objects.

        The parameter "tag" specifies the tag as a String

        The parameter "count" is optional and describes
        the amount of podcasts that are returned. The
        default value is 50, the minimum value is 1 and
        the maximum value is 100.
        """
        uri = self._locator.podcasts_of_a_tag_uri(tag, count)
        return [simple.Podcast.from_dict(x) for x in self._client.GET(uri)]

    def get_toptags(self, count=mygpoclient.TOPLIST_DEFAULT):
        """Get a list of most-used tags

        Returns a list of Tag objects.

        The parameter "count" is optional and describes
        the amount of podcasts that are returned. The
        default value is 50, the minimum value is 1 and
        the maximum value is 100.
        """
        uri = self._locator.toptags_uri(count)
        return [Tag.from_dict(x) for x in self._client.GET(uri)]
    
    def get_podcast_data(self, podcast_uri):
        """Get Metadata for the specified Podcast
        
        Returns a simple.Podcast object.
        
        The parameter "podcast_uri" specifies the URL of the Podcast.
        """
        uri = self._locator.podcast_data_uri(podcast_uri)
        return simple.Podcast.from_dict(self._client.GET(uri))
    
    def get_episode_data(self, podcast_uri, episode_uri):
        """Get Metadata for the specified Episode
        
        Returns a Episode object.
        
        The parameter "podcast_uri" specifies the URL of the Podcast,
        which this Episode belongs to
        
        The parameter "episode_uri" specifies the URL of the Episode
        """
        uri = self._locator.episode_data_uri(podcast_uri, episode_uri)
        return Episode.from_dict(self._client.GET(uri))