Skip to content
This repository has been archived by the owner on Jun 30, 2022. It is now read-only.

Commit

Permalink
Merge pull request #177 from fabi321/channel-playlist-search
Browse files Browse the repository at this point in the history
Fetch Playlists from channels
  • Loading branch information
mytja committed May 2, 2022
2 parents 9bbc3d2 + b94923d commit f6c0fa2
Show file tree
Hide file tree
Showing 15 changed files with 265 additions and 557 deletions.
279 changes: 28 additions & 251 deletions README.md
Expand Up @@ -2285,257 +2285,6 @@ print(Channel.get("UC_aEa8K-EOJ3D6gOs7HcyNg"))
"height": 200
}
],
"availableCountryCodes": [
"ET",
"NU",
"PW",
"RS",
"NP",
"CC",
"PY",
"CH",
"FO",
"BH",
"AO",
"EE",
"SX",
"GG",
"SS",
"RE",
"GP",
"PR",
"TZ",
"YT",
"ZW",
"SH",
"SG",
"GE",
"SA",
"GN",
"TW",
"SJ",
"HN",
"UZ",
"GR",
"ML",
"NC",
"PE",
"BY",
"SE",
"MO",
"TO",
"MU",
"YE",
"GB",
"AI",
"PS",
"AQ",
"RW",
"FI",
"KW",
"CX",
"CD",
"LI",
"BI",
"MZ",
"SM",
"BS",
"CA",
"SB",
"LC",
"BJ",
"DO",
"CO",
"CL",
"BM",
"HR",
"MK",
"PG",
"GI",
"LS",
"GU",
"KP",
"BO",
"TC",
"KN",
"TJ",
"AZ",
"HM",
"HT",
"VA",
"VN",
"IM",
"DK",
"SL",
"GL",
"EG",
"NL",
"NG",
"IQ",
"DZ",
"PL",
"TD",
"LU",
"CK",
"ST",
"TK",
"AS",
"VE",
"CN",
"MG",
"AL",
"BA",
"MV",
"AT",
"FJ",
"US",
"VI",
"AD",
"DJ",
"VU",
"MQ",
"SY",
"ES",
"AW",
"LY",
"NZ",
"TG",
"CF",
"NO",
"RO",
"CY",
"GF",
"KH",
"BG",
"IL",
"MX",
"TH",
"AG",
"LB",
"TV",
"GT",
"KZ",
"GD",
"JO",
"TT",
"KR",
"LV",
"VC",
"AR",
"TM",
"DM",
"NR",
"DE",
"SO",
"HU",
"VG",
"MY",
"BZ",
"FK",
"WS",
"CR",
"GS",
"SV",
"NA",
"GW",
"JM",
"JP",
"KI",
"TR",
"BW",
"CI",
"CW",
"AU",
"TF",
"LA",
"MS",
"GH",
"MN",
"PN",
"BT",
"ZA",
"AX",
"GM",
"IT",
"IR",
"MW",
"UM",
"MR",
"CZ",
"BF",
"ZM",
"TL",
"BV",
"PA",
"LT",
"MC",
"CG",
"ID",
"GA",
"KY",
"MP",
"NE",
"JE",
"IO",
"KM",
"ER",
"NF",
"MF",
"UG",
"EH",
"SR",
"UY",
"WF",
"BL",
"MD",
"IE",
"SK",
"SC",
"MA",
"FM",
"SZ",
"GY",
"MT",
"IN",
"SI",
"PH",
"CM",
"SD",
"CU",
"KG",
"PT",
"BB",
"AF",
"BN",
"LK",
"SN",
"OM",
"PF",
"BE",
"CV",
"AE",
"AM",
"BR",
"BQ",
"TN",
"MM",
"BD",
"GQ",
"KE",
"IS",
"QA",
"LR",
"PM",
"EC",
"RU",
"HK",
"UA",
"MH",
"NI",
"PK",
"FR",
"ME"
],
"isFamilySafe": true,
"keywords": "NoCopyrightSounds ncs no copyright sounds copyrighted music free royalty royaltyfree uncopyrighted copyrightfree",
"tags": [
Expand All @@ -2560,6 +2309,28 @@ print(Channel.get("UC_aEa8K-EOJ3D6gOs7HcyNg"))
</details>



#### Retrieve channel playlists
```py
from youtubesearchpython import Channel

channel = Channel("UC_aEa8K-EOJ3D6gOs7HcyNg")
print(len(channel.result["playlists"]))
while channel.has_more_playlists():
channel.next()
print(len(channel.result["playlists"]))
```

<details>
<summary> Example Result</summary>

```
30
49
```
</details>


## Contributors
Thanks to everyone contributing to this library, including those not mentioned here.

Expand All @@ -2586,6 +2357,12 @@ Contributors are added irrespective of order.
<li>Maintainer and reviewer of PRs. Author of Hashtag class.</li>
</ul>
</li>
<li>
<img src='https://avatars.githubusercontent.com/u/42294590?v=4' height='28' width='28'></img>&nbsp;&nbsp;<strong><a href='https://github.com/fabi321'>Fabian Wunsch</a></strong>
<ul>
<li>Fixes to ChannelSearch & retrieving Playlists from Channel class</li>
</ul>
</li>
<li>
<img src='https://avatars.githubusercontent.com/u/1645646?v=4' height='28' width='28'></img>&nbsp;&nbsp;<strong><a href='https://github.com/Zocker1999NET'>Felix Stupp</a></strong>
<ul>
Expand Down
9 changes: 9 additions & 0 deletions asyncExample.py
Expand Up @@ -233,6 +233,15 @@ async def main():
print(await Channel.get("UC_aEa8K-EOJ3D6gOs7HcyNg"))


# Retrieve playlists of a channel
channel = Channel("UC_aEa8K-EOJ3D6gOs7HcyNg")
await channel.init()
print(len(channel.result["playlists"]))
while channel.has_more_playlists():
await channel.next()
print(len(channel.result["playlists"]))




'''
Expand Down
8 changes: 8 additions & 0 deletions syncExample.py
Expand Up @@ -235,6 +235,14 @@
print(Channel.get("UC_aEa8K-EOJ3D6gOs7HcyNg"))


# Retrieve playlists of a channel
channel = Channel("UC_aEa8K-EOJ3D6gOs7HcyNg")
print(len(channel.result["playlists"]))
while channel.has_more_playlists():
channel.next()
print(len(channel.result["playlists"]))



'''
You may add/omit the optional parameters according to your requirement & use case.
Expand Down
8 changes: 8 additions & 0 deletions tests/async/extras.py
Expand Up @@ -49,5 +49,13 @@ async def main():

print(await Channel.get("UC_aEa8K-EOJ3D6gOs7HcyNg"))

# Retrieve playlists of a channel
channel = Channel("UC_aEa8K-EOJ3D6gOs7HcyNg")
await channel.init()
print(len(channel.result["playlists"]))
while channel.has_more_playlists():
await channel.next()
print(len(channel.result["playlists"]))


asyncio.run(main())
12 changes: 11 additions & 1 deletion tests/async/search.py
Expand Up @@ -32,8 +32,18 @@ async def main():
print(result)

channel = ChannelSearch('The Beatles - Topic', 'UC2XdaAVUannpujzv32jcouQ')
result = await search.next()
result = await channel.next()
print(result)

"""
channel = ChannelPlaylistSearch('PewDiePie', 'UC-lHJZR3Gqxm24_Vd_AJ5Yw')
result = await channel.next()
print(result)
channel = ChannelPlaylistSearch('The Beatles - Topic', 'UC2XdaAVUannpujzv32jcouQ')
result = await channel.next()
print(result)
"""


search = VideosSearch('NoCopyrightSounds')
Expand Down

0 comments on commit f6c0fa2

Please sign in to comment.