-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
243 lines (196 loc) · 9.34 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?php
use Ashkanfekridev\RadioJavan;
require_once __DIR__ . '/vendor/autoload.php';
$options = ['proxy' => 'socks5h://127.0.0.1:2080'];
//$options = [];
$media = [];
/*$response = json_decode(file_get_contents(__DIR__ . '/clone.json'));
$media['title'] = $response->props->pageProps->playlist->title;
$media['desc'] = $response->props->pageProps->playlist->desc;
$media['photo'] = $response->props->pageProps->playlist->photo;
$media['created_title'] = $response->props->pageProps->playlist->created_title;
$count = 1;
foreach ($response->props->pageProps->playlist->items as $item) {
$media['items'][] = [
'title' => $item->title,
'link'=>$item->link,
'photo'=>$item->photo,
'count'=>$count++
];
}
echo json_encode($media);
return;*/
if (isset($_GET['url'])) {
try {
$radio = new RadioJavan($_GET['url'], $options);
// echo json_encode($radio->getResponse());
// return;
// echo (json_decode($fakeData)->props);
// return;
if ($radio->getType() === '') {
throw new Exception("مشکل در واکشی اطلاعات از سمت سرور: لینک نا معتبر!");
}
$media['type'] = $radio->getType();
switch ($media['type']):
case 'video':
$media['title'] = $radio->getMediaTitle();
$media['photo'] = $radio->getMediaPhoto();
$media['photo'] = $radio->getMediaThumbnail();
$media['link'] = $radio->getMediaLink();
break;
case "podcast":
case "song":
$media['title'] = $radio->getMediaTitle();
$media['photo'] = $radio->getMediaPhoto();
$media['link'] = $radio->getMediaLink();
break;
case "artist":
$media['title'] = $radio->getArtistName();
$media['photo'] = $radio->getArtistPhoto_thumb();
$media['albums'] = $radio->getArtistAlbums();
$media['mp3s'] = $radio->getArtistMp3s();
$media['videos'] = $radio->getArtistVideos();
break;
case "album":
$response = $radio->getResponse();
$media['photo'] = $response->props->pageProps->media->photo;
$media['title'] = $response->props->pageProps->media->title;
$media['tracks'] = $response->props->pageProps->media->album_tracks;
break;
case "playlist":
$response = $radio->getResponse();
$media['title'] = $response->props->pageProps->playlist->title;
$media['desc'] = isset($response->props->pageProps->playlist->desc) ?? null;
$media['photo'] = $response->props->pageProps->playlist->photo;
$media['created_title'] = $response->props->pageProps->playlist->created_title;
$count = 1;
foreach ($response->props->pageProps->playlist->items as $item) {
$media['items'][] = [
'title' => $item->title,
'link' => $item->link,
'photo' => $item->photo,
'count' => $count++
];
}
break;
default:
throw new Exception("لینک نا معتبر!");
endswitch;
} catch (Exception $exception) {
return die($exception);
}
}
?>
<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio,line-clamp,container-queries"></script>
</head>
<body>
<div id="app">
<div class="container mx-auto max-w-xl p-8 prose lg:prose-xl">
<form action="/">
<label for="url">لینک مورد نظر از رادیو جوان</label>
<input type="text" id="url" name="url"
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50">
<button type="submit"
class="min-w-full mt-3 justify-center rounded-lg text-sm font-semibold py-3 px-4 bg-slate-900 text-white hover:bg-slate-700 block">
تبدیل
</button>
</form>
<div>
<!--video-->
<?php if (isset($media['type']) && $media['type'] === 'video') {
?>
<p><?= $media['title']; ?></p>
<img src="<?= $media['photo']; ?>" class="min-w-full">
<a href="<?= $media['link']; ?>"
class="text-center min-w-full mt-3 justify-center rounded-lg text-sm font-semibold py-3 px-4 bg-slate-900 text-white hover:bg-slate-700 block">دانلود</a>
<?php
} ?>
<!--song-->
<?php if (isset($media['type']) && $media['type'] === 'song' || isset($media['type']) && $media['type'] === 'podcast') {
?>
<p><?= $media['title']; ?></p>
<img src="<?= $media['photo']; ?>" class="min-w-full">
<a href="<?= $media['link']; ?>"
class="text-center min-w-full mt-3 justify-center rounded-lg text-sm font-semibold py-3 px-4 bg-slate-900 text-white hover:bg-slate-700 block">دانلود</a>
<?php
} ?>
<!--album-->
<?php if (isset($media['type']) && $media['type'] === 'album') {
?>
<p><?= $media['title']; ?></p>
<img src="<?= $media['photo']; ?>" class="min-w-full">
<?php foreach ($media['tracks'] as $track) { ?>
<a href="<?= $track->link; ?>"
class="text-center min-w-full mt-3 justify-center rounded-lg text-sm font-semibold py-3 px-4 bg-slate-900 text-white hover:bg-slate-700 block">دانلود: <?= $track->title; ?></a>
<?php
}
} ?>
<!--playlist-->
<?php if (isset($media['type']) && $media['type'] === 'playlist') {
?>
<h1 class="text-xl text-center"><?= $media['title']; ?></h1>
<h3 class="text-lg text-center"><?= $media['created_title']; ?></h3>
<?php if (isset($media['desc'])) { ?>
<p class="text-base text-center"><?= $media['desc']; ?></p>
<?php } ?>
<img src="<?= $media['photo']; ?>" class="min-w-full">
<?php foreach ($media['items'] as $track) { ?>
<h1 class="text-base text-center"><?= $track['title']; ?></h1>
<img src="<?= $track['photo']; ?>" class="min-w-full">
<a href="<?= $track['link']; ?>"
class="text-center min-w-full mt-3 justify-center rounded-lg text-sm font-semibold py-3 px-4 bg-slate-900 text-white hover:bg-slate-700 block mb-16">دانلود: <?= $track['title']; ?></a>
<?php
}
} ?>
<!--artist-->
<?php if (isset($media['type']) && $media['type'] === 'artist') {
?>
<p><?= $media['title']; ?></p>
<img src="<?= $media['photo']; ?>" class="min-w-full">
<div>
<h3>Albums</h3>
<ul>
<?php foreach ($media['albums'] as $album): ?>
<li>
<img src="<?= $album->photo; ?>" class="min-w-full">
<a href="/?url=<?= $album->share_link; ?>"><?= $album->title; ?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
<div>
<h3>songs</h3>
<ul>
<?php foreach ($media['mp3s'] as $mp3): ?>
<li>
<img src="<?= $mp3->photo; ?>" class="min-w-full">
<a href="<?= $mp3->link; ?>"><?= $mp3->title; ?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
<div>
<h3>videos</h3>
<ul>
<?php foreach ($media['videos'] as $video): ?>
<li>
<img src="<?= $video->photo; ?>" class="min-w-full">
<a href="<?= $video->link; ?>"><?= $video->title; ?></a>
</li>
<?php endforeach; ?>
</ul>
</div>
<?php } ?>
</div>
</div>
</div>
</body>
</html>