Get the label of the song at a given time in seconds
185355
def label(self, t):
        
        if self.labels is None:
            return None
        prev_label = None
        for l in self.labels:
            if l.time > t:
                break
            prev_label = l
        if prev_label is None:
            return None
        return prev_label.name
1320193
def _track_from_response(result, timeout):
    
    response = result['response']
    status = response['track']['status'].lower()

    if status == 'pending':
        # Need to wait for async upload or analyze call to finish.
        result = _wait_for_pending_track(response['track']['id'], timeout)
        response = result['response']
        status = response['track']['status'].lower()

    if not status == 'complete':
        track_id = response['track']['id']
        if status == 'pending':
            raise Exception('%s: the operation didn\'t complete before the timeout (%d secs)' %
                            (track_id, timeout))
        else:
            raise Exception('%s: there was an error analyzing the track, status: %s' % (track_id, status))
    else:
        # track_properties starts as the response dictionary.
        track_properties = response['track']
        # 'id' and 'md5' are separated to construct the Track object.
        identifier = track_properties.pop('id')
        md5        = track_properties.pop('md5', None) # tracks from song api calls will not have an md5
        # Pop off the audio_summary dict and make those keys attributes
        # of the Track. This includes things like tempo, energy, and loudness.
        track_properties.update(track_properties.pop('audio_summary'))
        return Track(identifier, md5, track_properties)
418837
private void parseMetadataItem(Message item) {
        switch (item.getMenuItemType()) {
            case TRACK_TITLE:
                title = ((StringField) item.arguments.get(3)).getValue();
                artworkId = (int) ((NumberField) item.arguments.get(8)).getValue();
                break;

            case ARTIST:
                artist = buildSearchableItem(item);
                break;

            case ORIGINAL_ARTIST:
                originalArtist = buildSearchableItem(item);
                break;

            case REMIXER:
                remixer = buildSearchableItem(item);

            case ALBUM_TITLE:
                album = buildSearchableItem(item);
                break;

            case LABEL:
                label = buildSearchableItem(item);
                break;

            case DURATION:
                duration = (int) ((NumberField) item.arguments.get(1)).getValue();
                break;

            case TEMPO:
                tempo = (int) ((NumberField) item.arguments.get(1)).getValue();
                break;

            case COMMENT:
                comment = ((StringField) item.arguments.get(3)).getValue();
                break;

            case KEY:
                key = buildSearchableItem(item);
                break;

            case RATING:
                rating = (int) ((NumberField)item.arguments.get(1)).getValue();
                break;

            case COLOR_NONE:
            case COLOR_AQUA:
            case COLOR_BLUE:
            case COLOR_GREEN:
            case COLOR_ORANGE:
            case COLOR_PINK:
            case COLOR_PURPLE:
            case COLOR_RED:
            case COLOR_YELLOW:
                color = buildColorItem(item);
                break;

            case GENRE:
                genre = buildSearchableItem(item);
                break;

            case DATE_ADDED:
                dateAdded = ((StringField) item.arguments.get(3)).getValue();
                break;

            case YEAR:
                year = (int) ((NumberField) item.arguments.get(1)).getValue();
                break;

            case BIT_RATE:
                bitRate = (int) ((NumberField) item.arguments.get(1)).getValue();
                break;

            default:
                logger.warn("Ignoring track metadata item with unknown type: {}", item);
        }
    }
694769
function getLabel(children) {
  let str = '';

  if (Array.isArray(children)) {
    children.forEach(c => {
      if (Array.isArray(c)) {
        getLabel(c);
      } else if (c.props) {
        str = c.props.children;
      } else {
        str = c;
      }
    });
  } else if (children.props) {
    getLabel(children.props.children);
  } else {
    str = children;
  }

  return str;
}
1259350
def get_by_label(self, label):
        
        return next((x for x in self if x.label == label), None)
1093661
def get_now_playing(self):
        

        params = self._get_params()
        params["limit"] = "1"

        doc = self._request(self.ws_prefix + ".getRecentTracks", False, params)

        tracks = doc.getElementsByTagName("track")

        if len(tracks) == 0:
            return None

        e = tracks[0]

        if not e.hasAttribute("nowplaying"):
            return None

        artist = _extract(e, "artist")
        title = _extract(e, "name")

        return Track(artist, title, self.network, self.name)
135675
function getSignature (sp, fn) {
  var start = null
    , sig = ''
    , timer;

  var handleSignature = function(data) {
    if (data)
      sig += data.toString() || '';

    clearTimeout(timer);

    if (!start && data) {
      start = Date.now();
    } else if (Date.now() - start > 100) {
      sp.removeListener('data', handleSignature);
      return fn(null, sig.trim());
    }

    timer = setTimeout(handleSignature, 100);
  };

  sp.on('data', handleSignature);
}
985368
def get_first_song(self):
        
        count = 3
        while count > 0:
            song = self.requests_url('n')
            if song:
                return song
            count -= 1
            time.sleep(2)
        raise GenericError('获取第一首歌曲失败，无法完成初始化')
489209
function getTimestampString(date) {
    // all this nasty code is faster (~30k ops/sec) than doing "moment(date).format('HH:mm:ss:SSS')" and means 0 dependencies
    var hour = '0' + date.getHours();
    hour = hour.slice(hour.length - 2);
    var minute = '0' + date.getMinutes();
    minute = minute.slice(minute.length - 2);
    var second = '0' + date.getSeconds();
    second = second.slice(second.length - 2);
    var ms = '' + date.getMilliseconds();

    // https://github.com/MarkHerhold/palin/issues/6
    // this is faster than using an actual left-pad algorithm
    if (ms.length === 1) {
        ms = '00' + ms;
    } else if (ms.length === 2) {
        ms = '0' + ms;
    } // no modifications for 3 or more digits

    return chalk.dim(`${hour}:${minute}:${second}:${ms}`);
}
352555
private String getElapsedTimeLabel(long elapsed) {
        return (elapsed >= 0) ?
                String.format("%02d:%02d.%03d", elapsed / 60000, (elapsed % 60000) / 1000, (elapsed % 1000)) :
                null;
    }
181744
def _get_song(self):
        '''
        
        '''
        # Try to get the current track from the start metasong
        if self.at_beginning:
            # Make sure it exists.
            if self.pos < len(self.start):
                # It exists, so return it.
                return self.start[self.pos]
            # It doesn't exist, so let's move on!
            self.at_beginning = False
            # Generate a new track selection
            self._new_track()
        # A bit more difficult than using the start metasong, 
        # because we could have a beginning part. Call a function that gets all 
        # applicable tracks from the metasong.
        s = self._get_selectable()
        # Make sure it is long enough
        while self.pos >= len(s):
            # Or pick a new metasong.
            self._new_song()
            # And repeat.
            s = self._get_selectable()
        # Found a track, return it.
        return s[self.pos]
224479
def to_fasta(self):
        
        prefix, suffix = re.split('(?<=size=)\w+', self.label, maxsplit=1)
        new_count = int(round(self.frequency))
        new_label = "%s%d%s" % (prefix, new_count, suffix)
        return ">%s\n%s\n" % (new_label, self.sequence)
457350
def to_iso_time_string(self) -> str:
        
        short_time = self.to_short_time_string()
        second = self.time.second
        return f"{short_time}:{second:02}"
656749
def get(self):
        """"""
        elapsed = datetime.now() - self._previous
        self._previous += elapsed
        return elapsed.total_seconds()
285380
def get_label(self, label, params=None):
        
        return self.label(label, action='GET', params=params)
290543
def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
    """"""
    if not at:
        at = utcnow()
    return at.strftime(fmt)
1027784
private String toLabel(final TimeUnit unit) {
      switch(unit) {
         case DAYS: return "day";
         case HOURS: return "hour";
         case MINUTES: return "minute";
         case SECONDS: return "second";
         case MILLISECONDS: return "ms";
         case MICROSECONDS: return "us";
         case NANOSECONDS: return "ns";
         default: return "";
      }
   }