Add to_base62 method

This commit is contained in:
Sasha Hilton 2018-02-28 13:29:24 +01:00
parent a7334b6c23
commit cbc4ee7554
2 changed files with 7 additions and 3 deletions

View file

@ -1,7 +1,7 @@
use byteorder::{BigEndian, ByteOrder}; use byteorder::{BigEndian, ByteOrder};
use extprim::u128::u128;
use std; use std;
use std::fmt; use std::fmt;
use extprim::u128::u128;
// Unneeded since 1.21 // Unneeded since 1.21
#[allow(unused_imports)] #[allow(unused_imports)]
use std::ascii::AsciiExt; use std::ascii::AsciiExt;
@ -76,7 +76,7 @@ impl SpotifyId {
let mut data = [0u8; 22]; let mut data = [0u8; 22];
let sixty_two = u128::new(62); let sixty_two = u128::new(62);
for i in 0..22 { for i in 0..22 {
data[21-i] = BASE62_DIGITS[(n % sixty_two).low64() as usize]; data[21 - i] = BASE62_DIGITS[(n % sixty_two).low64() as usize];
n /= sixty_two; n /= sixty_two;
} }

View file

@ -533,7 +533,11 @@ impl PlayerInternal {
fn load_track(&self, track_id: SpotifyId, position: i64) -> Option<(Decoder, f32)> { fn load_track(&self, track_id: SpotifyId, position: i64) -> Option<(Decoder, f32)> {
let track = Track::get(&self.session, track_id).wait().unwrap(); let track = Track::get(&self.session, track_id).wait().unwrap();
info!("Loading track \"{}\" with Spotify URI \"{}\"", track.name, track_id.to_base62()); info!(
"Loading track \"{}\" with Spotify URI \"{}\"",
track.name,
track_id.to_base62()
);
let track = match self.find_available_alternative(&track) { let track = match self.find_available_alternative(&track) {
Some(track) => track, Some(track) => track,