Skip to content

Instantly share code, notes, and snippets.

@fushihara
Created August 9, 2012 17:20
Show Gist options
  • Save fushihara/3306110 to your computer and use it in GitHub Desktop.
Save fushihara/3306110 to your computer and use it in GitHub Desktop.
youtubeの動画ID
$index=1;
$results=[];
do{
$xml = simplexml_load_file('http://gdata.youtube.com/feeds/api/videos?vq=minecraft&max-results=50&start-index='.$index.'&orderby=relevance');
if(!$xml){break;}
foreach($xml->entry as $v){
preg_match('{.+/(.+?)$}',$v->id,$match);
$id=$match[1];
print $index." ".$id."\n";
$results[$id]=true;
$index++;
}
if($index>1000){break;}
youtubeVidLast($results);
}while(true);
function youtubeVidLast($vids){
//まずは数える
$result=[];
foreach($vids as $vid=>$true){
for($i=0;$i<11;$i++){
$oneString=substr($vid,$i,1);
// $oneString=strtoupper($oneString);
@$result[$i][$oneString]++;
}
}
//ksortする
// print_r($result[10]);
for($i=0;$i<11;$i++){
ksort($result[$i]);
}
//Aは…Bは…と入れなおす
$result2=[];
foreach($result as $strPos=>$v1){
foreach($v1 as $strType=>$strCount){
@$result2[$strType][$strPos]=$strCount;
}
}
ksort($result2);
//フォーマットして表示する
foreach($result2 as $strType=>$v1){
for($i=0;$i<11;$i++){
if(!isset($v1[$i])){$v1[$i]=0;}
}
printf("%s %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d\n",$strType,$v1[0],$v1[1],$v1[2],$v1[3],$v1[4],$v1[5],$v1[6],$v1[7],$v1[8],$v1[9],$v1[10]);
}
}
/*
文字 1文字目、2文字目…
A 18 12 25 28 19 11 16 17 14 16 71
B 26 21 18 16 27 12 20 18 23 28 00
C 20 12 14 13 16 13 14 21 21 23 00
D 15 22 17 19 13 19 16 25 18 24 00
E 19 08 23 23 22 15 15 19 18 13 61
F 24 18 13 21 13 14 25 27 18 17 00
G 26 26 24 20 28 16 17 19 24 18 00
H 09 16 16 19 21 20 15 15 22 15 00
I 20 15 18 16 14 21 13 22 19 19 87
J 29 24 15 11 14 18 13 33 22 22 00
K 12 21 19 23 18 28 22 11 15 16 00
L 21 19 19 27 10 21 17 19 15 09 00
M 21 18 15 23 15 13 25 08 15 18 71
N 21 29 21 20 14 18 19 16 18 21 00
O 08 17 14 25 25 14 25 15 26 12 00
P 26 15 26 20 21 21 17 17 23 15 00
Q 23 23 21 15 22 20 17 20 15 13 78
R 12 20 20 15 19 19 16 30 24 17 00
S 21 18 15 16 23 12 20 22 10 20 00
T 33 15 15 10 18 16 24 18 14 10 00
0 21 24 21 11 25 07 12 17 18 20 93
U 30 23 30 17 21 18 23 18 19 23 76
V 06 17 21 16 14 28 24 23 17 09 00
W 24 20 20 20 14 15 20 15 15 14 00
X 20 18 17 20 22 15 18 21 20 16 00
Y 10 14 20 24 19 36 18 21 24 19 75
Z 22 19 29 17 15 19 23 12 18 26 00
a 24 16 22 24 17 18 21 15 13 15 00
b 24 17 14 23 18 23 15 22 16 20 00
c 05 24 19 17 19 19 22 17 24 16 78
d 19 22 12 27 19 26 20 22 20 20 00
e 24 10 25 17 22 16 24 23 20 16 00
f 12 19 21 20 19 20 25 18 23 14 00
g 20 21 20 18 21 18 17 25 17 15 98
h 22 17 22 18 24 21 18 15 20 22 00
i 20 20 14 17 20 27 16 15 19 20 00
j 06 18 16 23 12 18 15 19 23 25 00
k 26 23 20 18 15 21 27 14 22 19 59
l 18 22 16 13 25 15 24 18 20 19 00
m 13 16 14 27 14 14 22 22 16 29 00
n 22 17 19 21 22 26 22 12 23 21 00
o 20 16 25 15 18 25 13 13 20 16 57
p 18 17 21 18 14 27 17 17 18 16 00
q 09 26 22 16 14 15 19 12 20 15 00
r 22 19 18 20 21 23 22 15 21 22 00
s 14 14 15 15 21 17 13 15 17 20 67
t 20 17 20 22 24 20 20 21 20 23 00
u 09 16 14 18 21 18 18 18 17 21 00
v 21 18 12 21 15 15 11 17 18 20 00
w 21 17 19 15 17 15 21 21 17 14 67
x 14 15 21 15 13 21 19 30 16 22 00
y 22 25 16 13 16 19 16 14 25 16 00
z 22 13 21 16 16 16 15 14 15 31 00
1 09 17 15 24 25 15 25 17 20 16 00
2 27 24 18 25 24 16 20 17 12 17 00
3 30 17 16 18 18 21 19 19 16 23 00
4 12 15 19 27 20 23 14 17 22 15 83
5 20 22 16 24 23 21 17 21 20 21 00
6 21 17 17 23 22 16 16 15 16 25 00
7 21 19 22 16 11 17 27 22 14 14 00
8 07 29 22 10 28 21 19 20 22 26 76
9 28 20 21 12 11 18 15 23 15 19 00
- 16 21 14 13 23 20 11 23 17 20 00
_ 02 17 13 13 13 17 18 20 18 21 00
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment