forum

osu!userbar

posted
Total Posts
45
Topic Starter
Arnold0
Hi,

A few days ago, I wanted to do a dynamic signature, which contains my data from 3 websites. I succeded, and this "Big ugly wthe" signature was on my signature for a few days.

But just a day after, I wanted to do a small and not too ugly thing instead, and modify my code so other users might be able to get one.
I got the idea of an userbar. It's a small 350x20 px bar, normaly with a small text, saying for exemple "osu! user".
But here I just did a dynamic userbar, with all needed data, so you and other people can easily see your osu statistics.

I fetch data from http://osu.ppy.sh/pages/include/profile ... u=$id&m=$g (where $id is your osu! user id and $g the gamemode id) and store them in a database.
When the image is called, the site read the data stored in the database, if the data is more than 3 hours old, it reads again on osu! website and, in each case it generate the image.
The image is always generated, nothing more than the police, the empty images and the php pages are on the server.
I'm using a free hosting service which only give 10MB of storage, so regenerate the image from the database is the only solution.

But I think this isn't important to regular users ;)

Here is the url : http://userbar.arnold0.com
The pages are white with black text, no desing, but that's not important, the important is the result, the userbars ^^
So don't mind these white pages, the site is fonctionnal :)
And the availlable userbars :





Hope you enjoy ;)

PS : If peppy ask me, I may change the time before fetching data again. (Actualy it's 3h).
Kyujuroku 96
Wow nice. I'm going to add this to the osu!compilation thread because its AWESOME
Kurai
Do it for all game modes now !
Topic Starter
Arnold0
What append if I say no ?
Seriously I may try but that imply some changes.

EDIT : Okay I'm doing it, so the site may bug.
Blaziken
Me like.
Damnae
Mine looks better :D
Topic Starter
Arnold0
Ok damnae.
I've done a partial support for other gamemodes but I need to change a little more because actualy the "osu" is on the original image si I need to change the image and modify the code for writing the text

EDIT : Other gamemodes done (Was not as hard as I was thinking ^^")

But I sometimes got :
Warning: file_get_contents(http://osu.ppy.sh/u/arnold0) [function.file-get-contents]: failed to open stream: HTTP request failed! in /home/arnold0/www/index.php on line 31
Fetching data failed...

It looks like osu!website is buggy (Forum pages sometimes give me error 502 or are long to load actualy)
Outsanity
This is slick.
Dexus
I wish you had a theme for the bar that actually resembles the way osu! looks and isn't hard to read like most of them. The text is white and the colors are bright making it really difficult to read. You should use analogous or complimentary colors when deciding colors for themes so it will look aesthetically pleasing and view-able.

The only ones that work well are your first example for osu! and your example for mania. The rest have the text blend into the background by how bright it is. Just look at the level for Taiko, you can't even read it.
Topic Starter
Arnold0
Updated for using osu!api.
Old registered userbars may take up to 3 hours until becoming working again

Before the rank was recorded in #XXX,XXX format but osu!api give it as XXXXXX si I need to do a number_format for adding the , and the number_format don't work with actual recorded data.

I took an random username, as you can see it's working fine with new registered users.
Winshley





Um... I think I broke the Accuracy display. :?
XPJ38
Winshley too stronk for userbars

There's also a problem with some accuracies. The following userbar shows your (Arnold0's) CtB stats with an acc of 98.7600% (osu!api returns exactly "98.76").


(if I'm not mistaken, you are deleting the last two characters of the acc string returned by osu!api. This would explain Winshley's 1%. Don't do that and use number_format() instead!)
(are you directly manipulating the JSON string returned by osu!api without decoding it? There's a PHP function called json_decode() you know :P)

You should also use a dot instead of a comma as a decimal separator for the score.
Remyria
very nice userbar :)
Aoko
This is really great. I love this ♥
Topic Starter
Arnold0
Winshley having 100% accuracy is considerated cheating so it say 1%. Nope ^^

No seriously, you're right saying that I just deleted the last two digit of accuracy. I didn't know that osu!api delete the last 2 (or 4 in case of 100%) useless digit of accuracy. I may have to get the full accuracy string and use number_format

Also what is JSON ?! I just use that for getting data (exemple for score) :
$osu=file_get_contents("http://osu.ppy.sh/api/get_user?k=MYKEY&u=$id&m=$g");
$rankedscore=strstr($osu,'ranked_score');
$pos=strpos($rankedscore,'","');
$rankedscore=substr($rankedscore,15,($pos-15));

Is that wrong ? Is JSON faster / Easyer to use ?

I will fix it monday I think, I won't have a PC before.
Piotrekol

Arnold0 wrote:

Is that wrong ? Is JSON faster / Easyer to use ?
Yes it is wrong. just use Json_decode() function and it should give you a easy to use array.
YunoFanatic
i want to but im wondering or this is curiosity how can i click the picture then an website will come out many of player have that for example deni has a banner ''Mapper Help Team'' and when ever i click i always go to the mapper help team thread pls answer btw i like that mind creating me some?
pixeldesu

YunoFanatic wrote:

i want to but im wondering or this is curiosity how can i click the picture then an website will come out many of player have that for example deni has a banner ''Mapper Help Team'' and when ever i click i always go to the mapper help team thread pls answer btw i like that mind creating me some?
This is easy, just do this:
[url=yoururlhere][img]yourimagelink[/img][/url]
Piotrekol
@up ninja'd ._.
[url=<WEBSITE_ADRESS>][img]<LINK_TO_PICTURE>[/img][/url]

for ex:
[url=http://www.google.pl][img]http://userbar.arnold0.com/userbar4.php?id=304520[/img][/url]
gives me this:

ExBia
I'm adding it lol
YunoFanatic

Piotrekol wrote:

@up ninja'd ._.
[url=<WEBSITE_ADRESS>][img]<LINK_TO_PICTURE>[/img][/url]

for ex:
[url=http://www.google.pl][img]http://userbar.arnold0.com/userbar4.php?id=304520[/img][/url]
gives me this:

Thanks a million!
XPJ38

Arnold0 wrote:

...
Oh wow lol. "A JSON list containing user information" on the GitHub wiki should have given you a clue though :P
JSON is an international standard to easily encode and send data throughout webpages. It's especially used in Javascript/AJAX. Here are some var_dumps to make you understand:

Without json_decode, you get:

string '[{"user_id":"1428609","username":"Arnold0","count300":"1953","count100":"318","count50":"2933","playcount":"11","ranked_score":"1412132","total_score":"2437922","pp_rank":"276967","level":"7.29994","pp_raw":"9.05734","accuracy":"98.76","country":"FR"}]' (length=252)

With json_decode, you get:

array (size=1)
0 =>
array (size=13)
'user_id' => string '1428609' (length=7)
'username' => string 'Arnold0' (length=7)
'count300' => string '1953' (length=4)
'count100' => string '318' (length=3)
'count50' => string '2933' (length=4)
'playcount' => string '11' (length=2)
'ranked_score' => string '1412132' (length=7)
'total_score' => string '2437922' (length=7)
'pp_rank' => string '276967' (length=6)
'level' => string '7.29994' (length=7)
'pp_raw' => string '9.05734' (length=7)
'accuracy' => string '98.76' (length=5)
'country' => string 'FR' (length=2)

Arnold0 wrote:

I didn't know that osu!api delete the last 2 (or 4 in case of 100%) useless digit of accuracy.
iirc PHP or MySQL does that automatically.
Repflez

Arnold0 wrote:

$osu=file_get_contents("http://osu.ppy.sh/api/get_user?k=MYKEY&u=$id&m=$g");
Oh dear... Use cURL at least. file_get_contents is really slow and it should be used if your host doesn't have cURL installed.

Here's the method I use for calling API URLs and uses file_get_contents if cURL isn't installed (Even most free hosting have cURL installed but disable file_get_contents :P).

SPOILER
function get_url($url) {
global $appName, $appURL, $appVersion, $appEmail;
// Do we have cURL installed?
if (function_exists('curl_init')) {
// Yes, do our magic.
$ch = curl_init();
$options = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_HTTPHEADER => array('Content-type: application/json') ,
CURLOPT_USERAGENT => $appName . '/' . $appVersion . ' (' . $appURL . '; ' . $appEmail . ') osu!APIlib (https://github.com/Repflez/osu-API-lib)',
);
curl_setopt_array( $ch, $options );
$content = curl_exec($ch);
curl_close($ch);
} else {
// No, use the slower file_get_contents.
$content = file_get_contents($url);
}
return $content;
}

Arnold0 wrote:

$pos=strpos($rankedscore,'","');
$rankedscore=substr($rankedscore,15,($pos-15));
Wait, what? No offense but what made you think that manipulating directly the string was a good idea? I would explain json_decode but XPJ38 did it first.
Using json_decode($osu, true) should give you a common array with the data you need from the API.
Topic Starter
Arnold0
I didn't even known what iscURL... I'm noob -_-
I'm now using your fonction, then this :
$osudec=json_decode($osu);
$rankedscore=$osudec[0]->ranked_score;
$acc=$osudec[0]->accuracy;
$lvl=$osudec[0]->level;
$rank=$osudec[0]->pp_rank;

Realy easyer ;_;

The "100%" and "0%" accuracy is fixed
Score now use . insted of , .

PS Winshley why you are level 28 mania with 0 score, 0% accuracy ?!?
Winshley

Arnold0 wrote:

PS Winshley why you are level 28 mania with 0 score, 0% accuracy ?!?
Because I did have played osu!mania, but didn't complete the whole song because I kept on failing to get SS. :(

Which means all the level, scores (not Ranked Score) and accuracy are from failed plays.
XPJ38

Arnold0 wrote:

PS Winshley why you are level 28 mania with 0 score, 0% accuracy ?!?
Because of this:

'total_score' => string '144063600' (length=9)
(level is based on total score)
MaxiMilliaN_old
I want Score Ranking version.
Can you make Score Ranking version ?
If you can make Score Ranking version I'll so happy :3
Thank you~ :)
AlexSant
can you use a different font color, in some bars the white in background make it hard to read.
Piotrekol

AlexSant wrote:

can you use a different font color, in some bars the white in background make it hard to read.
or just add 1px black border to letters/numbers ;)

also round level down not up ;)


{"user_id":"304520","username":"Piotrekol",........,"level":"100.864".............}
Avail_old_1
Or just floor it instead of rounding it?
RavenMac
I like it. Not sure if you could do this, but i'm just throwing it out there.
If users could link to an image they want as the BG.
Maybe setup a template for users to work off of, or shrink/stretch images to fit?

Some of the ones available are hard to read, and there's a lack of different colors and styles.
troke
source please?
Howl

-Troke- wrote:

source please?
Do you really need the source code of this? Come on, you can make something similiar in one or two days of coding in php. It's pretty simple from what I can see.
troke
I could not make it, but I can edit it.
I just learned about php, I had previously understood. html
Howl
Here's something similiar for you: https://bitbucket.org/TheHowl/osuuserbarclone/src
Please note: this isn't meant to be used publicily, since at the moment makes an API request every time the image is loaded and that bursts up fast the API requests. Use this only as reference.
As I said, I took even less than 2 days. It isn't a full clone, but still it works with a few edits. Time to do it: 4 hours.
EDIT: Change the value of the api key in the config.php file since it won't work without that changed!
troke

TheHowl wrote:

Here's something similiar for you: https://bitbucket.org/TheHowl/osuuserbarclone/src
Please note: this isn't meant to be used publicily, since at the moment makes an API request every time the image is loaded and that bursts up fast the API requests. Use this only as reference.
As I said, I took even less than 2 days. It isn't a full clone, but still it works with a few edits. Time to do it: 4 hours.
EDIT: Change the value of the api key in the config.php file since it won't work without that changed!
thank you, i am make this for private not public
show more
Please sign in to reply.

New reply