aajanki / yle-dl

Download videos from Yle servers
https://aajanki.github.io/yle-dl/index-en.html
GNU General Public License v3.0
302 stars 52 forks source link

Possible replacement for removed API #307

Closed juntuu closed 2 years ago

juntuu commented 2 years ago

Hi,

Regarding the removal of old areena apis in https://github.com/aajanki/yle-dl/commit/5f3b6246213b76fb0af60eef96caabbb5141d615

I don't know much about the old api's schema, but with some cursory testing it would seem that /v3/schema/{schema_version}/items/{id} could be a pretty reasonable replacement for the old api.

Reverting the mentioned commit and changing the api endpoint seems to "just work". As said, I don't know the old schema, but it was able to produce at least the old default title format with series title, season and episode numbers.

diff --git a/yledl/extractors.py b/yledl/extractors.py
index aa0831b..26bdec7 100644
--- a/yledl/extractors.py
+++ b/yledl/extractors.py
@@ -715,7 +715,7 @@ class AreenaExtractor(ClipExtractor):

     def program_info_url(self, program_id):
         return (
-            f'https://areena.yle.fi/api/programs/v1/id/{quote_plus(program_id)}.json'
+            f'https://programs.api.yle.fi/v3/schema/v1/items/{quote_plus(program_id)}'
             '?app_id=areena_web_frontend_prod'
             '&app_key=4622a8f8505bb056c956832a70c105d4'
         )

Ps. I noticed there was a new release :tada: as I was writing this, but seeing the TODO in extract_season_number() I think this could still be relevant.

aajanki commented 2 years ago

Thanks for posting this. I didn't realise that the old API was that easy to replace. I don't necessarily want to get back to the old code structure but I could at least replace the HTML parsing in extract_season_number() with the programs API cal to make it more robust.