Exemple #1
0
    def track_end(
        self, lid, position, seeks=None, latency=150, context="unknown", source=None, reason=None, referrer=None
    ):
        """
        :type lid: str
        :type position: int
        :type seeks: dict {'num_forward', 'num_backward', 'ms_forward', 'ms_backward'}
        :type latency: int
        :type context: str
        :type source: dict {'start', 'end'}
        :type reason: dict {'start', 'end'}
        :type referrer: dict {'referrer', 'version', 'vendor'}
        :return:
        """

        seeks = set_defaults(seeks, {"num_forward": 0, "num_backward": 0, "ms_forward": 0, "ms_backward": 0})

        source = set_defaults(source, {"start": "unknown", "end": "unknown"})

        reason = set_defaults(reason, {"start": "unknown", "end": "unknown"})

        referrer = set_defaults(referrer, {"referrer": "unknown", "version": "0.1.0", "vendor": "com.spotify"})

        return self.send(
            "sp/track_end",
            lid,
            # Timings
            position,  # ms_played
            position,  # ms_played_union
            # Seek count
            seeks["num_forward"],
            seeks["num_backward"],
            seeks["ms_forward"],
            seeks["ms_backward"],
            latency,
            # Context
            str(self.uri),
            context,
            # Source
            source["start"],
            source["end"],
            # Reason
            reason["start"],
            reason["end"],
            # Referrer
            referrer["referrer"],
            referrer["version"],
            referrer["vendor"],
            position,  # max_continuous
        )
Exemple #2
0
    def track_progress(
        self, lid, position, source="unknown", reason="unknown", latency=150, context="unknown", referrer=None
    ):
        """
        :type lid: str
        :type position: int
        :type source: str
        :type reason: str
        :type latency: int
        :type context: str
        :type referrer: dict {'referrer', 'version', 'vendor'}
        :return:
        """

        referrer = set_defaults(referrer, {"referrer": "unknown", "version": "0.1.0", "vendor": "com.spotify"})

        return self.send(
            "sp/track_progress",
            lid,
            # Start
            source,
            reason,
            # Timings
            position,
            latency,
            # Context
            context,
            str(self.uri),
            # Referrer
            referrer["referrer"],
            referrer["version"],
            referrer["vendor"],
        )
Exemple #3
0
    def prepare(self):
        params = set_defaults(self.params, self.base_params)
        params['dt'] = time.strftime("%Y-%m-%dT%H:%M:%S")
        params['region'] = self.sp.country or 'us'

        query = urllib.urlencode(params)

        self.url = self.base_url % (self.name, query)
    def prepare(self):
        params = set_defaults(self.params, self.base_params)
        params["dt"] = time.strftime("%Y-%m-%dT%H:%M:%S")
        params["region"] = self.sp.country or "us"

        query = urllib.urlencode(params)

        self.url = self.base_url % (self.name, query)
Exemple #5
0
    def track_progress(self,
                       lid,
                       position,
                       source='unknown',
                       reason='unknown',
                       latency=150,
                       context='unknown',
                       referrer=None):
        """
        :type lid: str
        :type position: int
        :type source: str
        :type reason: str
        :type latency: int
        :type context: str
        :type referrer: dict {'referrer', 'version', 'vendor'}
        :return:
        """

        referrer = set_defaults(referrer, {
            'referrer': 'unknown',
            'version': '0.1.0',
            'vendor': 'com.spotify'
        })

        return self.send(
            'sp/track_progress',
            lid,

            # Start
            source,
            reason,

            # Timings
            position,
            latency,

            # Context
            context,
            str(self.uri),

            # Referrer
            referrer['referrer'],
            referrer['version'],
            referrer['vendor'],
        )
Exemple #6
0
    def track_progress(self, lid, position, source='unknown', reason='unknown', latency=150,
                       context='unknown', referrer=None):
        """
        :type lid: str
        :type position: int
        :type source: str
        :type reason: str
        :type latency: int
        :type context: str
        :type referrer: dict {'referrer', 'version', 'vendor'}
        :return:
        """

        referrer = set_defaults(referrer, {
            'referrer': 'unknown',
            'version': '0.1.0',
            'vendor': 'com.spotify'
        })

        return self.send(
            'sp/track_progress',
            lid,

            # Start
            source,
            reason,

            # Timings
            position,
            latency,

            # Context
            context,
            str(self.uri),

            # Referrer
            referrer['referrer'],
            referrer['version'],
            referrer['vendor'],
        )
Exemple #7
0
    def track_end(self, lid, position, seeks=None, latency=150, context='unknown',
                  source=None, reason=None, referrer=None):
        """
        :type lid: str
        :type position: int
        :type seeks: dict {'num_forward', 'num_backward', 'ms_forward', 'ms_backward'}
        :type latency: int
        :type context: str
        :type source: dict {'start', 'end'}
        :type reason: dict {'start', 'end'}
        :type referrer: dict {'referrer', 'version', 'vendor'}
        :return:
        """

        seeks = set_defaults(seeks, {
            'num_forward': 0,
            'num_backward': 0,
            'ms_forward': 0,
            'ms_backward': 0
        })

        source = set_defaults(source, {
            'start': 'unknown',
            'end': 'unknown'
        })

        reason = set_defaults(reason, {
            'start': 'unknown',
            'end': 'unknown'
        })

        referrer = set_defaults(referrer, {
            'referrer': 'unknown',
            'version': '0.1.0',
            'vendor': 'com.spotify'
        })

        return self.send(
            'sp/track_end',
            lid,

            # Timings
            position,  # ms_played
            position,  # ms_played_union

            # Seek count
            seeks['num_forward'],
            seeks['num_backward'],
            seeks['ms_forward'],
            seeks['ms_backward'],

            latency,

            # Context
            str(self.uri),
            context,

            # Source
            source['start'],
            source['end'],

            # Reason
            reason['start'],
            reason['end'],

            # Referrer
            referrer['referrer'],
            referrer['version'],
            referrer['vendor'],

            position  # max_continuous
        )
Exemple #8
0
    def track_end(self,
                  lid,
                  position,
                  seeks=None,
                  latency=150,
                  context='unknown',
                  source=None,
                  reason=None,
                  referrer=None):
        """
        :type lid: str
        :type position: int
        :type seeks: dict {'num_forward', 'num_backward', 'ms_forward', 'ms_backward'}
        :type latency: int
        :type context: str
        :type source: dict {'start', 'end'}
        :type reason: dict {'start', 'end'}
        :type referrer: dict {'referrer', 'version', 'vendor'}
        :return:
        """

        seeks = set_defaults(seeks, {
            'num_forward': 0,
            'num_backward': 0,
            'ms_forward': 0,
            'ms_backward': 0
        })

        source = set_defaults(source, {'start': 'unknown', 'end': 'unknown'})

        reason = set_defaults(reason, {'start': 'unknown', 'end': 'unknown'})

        referrer = set_defaults(referrer, {
            'referrer': 'unknown',
            'version': '0.1.0',
            'vendor': 'com.spotify'
        })

        return self.send(
            'sp/track_end',
            lid,

            # Timings
            position,  # ms_played
            position,  # ms_played_union

            # Seek count
            seeks['num_forward'],
            seeks['num_backward'],
            seeks['ms_forward'],
            seeks['ms_backward'],
            latency,

            # Context
            str(self.uri),
            context,

            # Source
            source['start'],
            source['end'],

            # Reason
            reason['start'],
            reason['end'],

            # Referrer
            referrer['referrer'],
            referrer['version'],
            referrer['vendor'],
            position  # max_continuous
        )