rfdl 1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
rfdl-1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Cosmow
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
rfdl-1/PKG-INFO ADDED
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: rfdl
3
+ Version: 1
4
+ Summary: A simple web scrapper tool wich downloads podcasts from radiofrance.
5
+ Home-page: https://github.com/Cosmow22/radio-france-dl
6
+ Author: Cosmow22
7
+ Author-email: cosmow543@gmail.com
8
+ License: MIT
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: license-file
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ # Radiofrance Podcast Downloader
27
+
28
+ Un CLI simple qui permet de télécharger un ou plusieurs podcasts de <https://www.radiofrance.fr/>.
29
+
30
+ ## Utilisation
31
+
32
+ Installer radio-france-dl :
33
+
34
+ ```batch
35
+ pip install rfdl
36
+ ```
37
+
38
+
39
+ Télécharger un podcast :
40
+
41
+ ```
42
+ rfdl lien
43
+ ```
44
+
45
+ Ou plusieurs podcasts en même temps en allant à la ligne :
46
+
47
+ ```
48
+ rfdl "lien1
49
+ lien2
50
+ "
51
+ ```
52
+
53
+ Par défaut, le podcast se télécharge dans le dossier courant. Pour spécifier le dossier cible, utiliser l'argument optionel output comme ça :
54
+
55
+ ```
56
+ rfdl lien --output "C:\Users\Marc\Desktop/podcasts"
57
+ ```
58
+
59
+ ## Licence
60
+
61
+ Ce projet est sous la license MIT. Soyer libre d'utiliser le code comme vous le voulez !
rfdl-1/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Radiofrance Podcast Downloader
2
+
3
+ Un CLI simple qui permet de télécharger un ou plusieurs podcasts de <https://www.radiofrance.fr/>.
4
+
5
+ ## Utilisation
6
+
7
+ Installer radio-france-dl :
8
+
9
+ ```batch
10
+ pip install rfdl
11
+ ```
12
+
13
+
14
+ Télécharger un podcast :
15
+
16
+ ```
17
+ rfdl lien
18
+ ```
19
+
20
+ Ou plusieurs podcasts en même temps en allant à la ligne :
21
+
22
+ ```
23
+ rfdl "lien1
24
+ lien2
25
+ "
26
+ ```
27
+
28
+ Par défaut, le podcast se télécharge dans le dossier courant. Pour spécifier le dossier cible, utiliser l'argument optionel output comme ça :
29
+
30
+ ```
31
+ rfdl lien --output "C:\Users\Marc\Desktop/podcasts"
32
+ ```
33
+
34
+ ## Licence
35
+
36
+ Ce projet est sous la license MIT. Soyer libre d'utiliser le code comme vous le voulez !
@@ -0,0 +1,2 @@
1
+ from .main import cli
2
+ from .rfdl import *
rfdl-1/rfdl/main.py ADDED
@@ -0,0 +1,48 @@
1
+ import asyncio
2
+ from pathlib import Path
3
+ from argparse import ArgumentParser
4
+ from re import compile
5
+ from .rfdl import *
6
+
7
+ INPUT_URL_PATTERN = compile(r"^https:\/\/www\.radiofrance\.fr\/(franceculture|franceinter)\/podcasts.*[0-9]{7}$")
8
+
9
+
10
+ def create_parser() -> ArgumentParser:
11
+ """Crée un analyseur syntaxique qui prend deux arguments : podcasts (obligatoire) et sortie (facultatif)."""
12
+ parser = ArgumentParser(
13
+ prog="rfscrapper",
14
+ description="Un CLI simple qui permet de télécharger des podcasts depuis radiofrance"
15
+ )
16
+ parser.add_argument(
17
+ "podcasts",
18
+ help="Le ou les liens vers le ou les podcasts que vous souhaitez télécharger. Vous pouvez fournir plusieurs liens en les séparant par un saut de ligne."
19
+ )
20
+ parser.add_argument(
21
+ "-o", "--output",
22
+ default=".", # current directory
23
+ help="Le dossier de sortie dans lequel vous souhaitez enregistrer vos téléchargements. Par défaut, il s'agit du répertoire du dossier actuel."
24
+ )
25
+ return parser
26
+
27
+
28
+ async def cli() -> None:
29
+ """Contains all the logic of the cli."""
30
+ parser = create_parser()
31
+ args = parser.parse_args()
32
+ podcasts_links: str = args.podcasts
33
+ output_folder: Path = Path.cwd() / args.output
34
+ output_folder.mkdir(exist_ok=True)
35
+
36
+ podcasts_links = podcasts_links.strip().split("\n")
37
+ for podcast_link in podcasts_links:
38
+ if INPUT_URL_PATTERN.match(podcast_link):
39
+ download_url = get_podcast_api_url(podcast_link)
40
+ file_path: Path = output_folder/get_podcast_name(podcast_link)
41
+ await save_podcast(file_path, download_url)
42
+ else:
43
+ print(f"[ERREUR] L'URL donnée est invalide:\n {podcast_link}")
44
+
45
+
46
+ def run():
47
+ """Exécute l'interface CLI de manière asynchrone."""
48
+ asyncio.run(cli())
rfdl-1/rfdl/rfdl.py ADDED
@@ -0,0 +1,37 @@
1
+ import asyncio
2
+ import requests
3
+ from re import compile
4
+
5
+
6
+ API_URL_PATTERN = compile(r"https://media\.radiofrance-podcast\.net\/(?!.*\.m4a).*?\.mp3")
7
+
8
+
9
+ async def save_podcast(file_path: str, link: str) -> None:
10
+ with requests.get(link, stream=True) as response:
11
+ response.raise_for_status()
12
+ with open(file_path, "wb") as fp:
13
+ for chunk in response.iter_content(chunk_size=8192):
14
+ fp.write(chunk)
15
+ print(f"Téléchargement réussi ! {file_path}")
16
+
17
+
18
+ def get_podcast_name(url) -> str:
19
+ url = url.split("/")
20
+ url = "-".join(url[5:])
21
+ url = url.split("-")
22
+ url = url[:-1]
23
+
24
+
25
+ url = " ".join(url)+".mp3"
26
+ return url
27
+
28
+
29
+ def get_podcast_api_url(url):
30
+ """Searches the api url for the podcast in the page source code."""
31
+ response = requests.get(url)
32
+ response.raise_for_status()
33
+ result = API_URL_PATTERN.search(response.text)
34
+ if result:
35
+ return result[0]
36
+ else:
37
+ raise Exception(f"Une erreur s'est produite lors du téléchargement : {url}")
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: rfdl
3
+ Version: 1
4
+ Summary: A simple web scrapper tool wich downloads podcasts from radiofrance.
5
+ Home-page: https://github.com/Cosmow22/radio-france-dl
6
+ Author: Cosmow22
7
+ Author-email: cosmow543@gmail.com
8
+ License: MIT
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Dynamic: author
16
+ Dynamic: author-email
17
+ Dynamic: classifier
18
+ Dynamic: description
19
+ Dynamic: description-content-type
20
+ Dynamic: home-page
21
+ Dynamic: license
22
+ Dynamic: license-file
23
+ Dynamic: requires-python
24
+ Dynamic: summary
25
+
26
+ # Radiofrance Podcast Downloader
27
+
28
+ Un CLI simple qui permet de télécharger un ou plusieurs podcasts de <https://www.radiofrance.fr/>.
29
+
30
+ ## Utilisation
31
+
32
+ Installer radio-france-dl :
33
+
34
+ ```batch
35
+ pip install rfdl
36
+ ```
37
+
38
+
39
+ Télécharger un podcast :
40
+
41
+ ```
42
+ rfdl lien
43
+ ```
44
+
45
+ Ou plusieurs podcasts en même temps en allant à la ligne :
46
+
47
+ ```
48
+ rfdl "lien1
49
+ lien2
50
+ "
51
+ ```
52
+
53
+ Par défaut, le podcast se télécharge dans le dossier courant. Pour spécifier le dossier cible, utiliser l'argument optionel output comme ça :
54
+
55
+ ```
56
+ rfdl lien --output "C:\Users\Marc\Desktop/podcasts"
57
+ ```
58
+
59
+ ## Licence
60
+
61
+ Ce projet est sous la license MIT. Soyer libre d'utiliser le code comme vous le voulez !
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ setup.py
4
+ rfdl/__init__.py
5
+ rfdl/main.py
6
+ rfdl/rfdl.py
7
+ rfdl.egg-info/PKG-INFO
8
+ rfdl.egg-info/SOURCES.txt
9
+ rfdl.egg-info/dependency_links.txt
10
+ rfdl.egg-info/entry_points.txt
11
+ rfdl.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ rfdl = rfdl.main:run
@@ -0,0 +1 @@
1
+ rfdl
rfdl-1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
rfdl-1/setup.py ADDED
@@ -0,0 +1,29 @@
1
+ from setuptools import setup, find_packages
2
+
3
+
4
+ with open("README.md") as fp:
5
+ long_description = fp.read()
6
+
7
+ setup(
8
+ name="rfdl",
9
+ version="1",
10
+ description="A simple web scrapper tool wich downloads podcasts from radiofrance.",
11
+ long_description=long_description,
12
+ long_description_content_type="text/markdown",
13
+ url="https://github.com/Cosmow22/radio-france-dl",
14
+ author="Cosmow22",
15
+ author_email="cosmow543@gmail.com",
16
+ license="MIT",
17
+ packages=find_packages(),
18
+ classifiers=[
19
+ "License :: OSI Approved :: MIT License",
20
+ "Programming Language :: Python :: 3",
21
+ "Operating System :: OS Independent",
22
+ ],
23
+ entry_points={
24
+ "console_scripts": [
25
+ "rfdl=rfdl.main:run",
26
+ ],
27
+ },
28
+ python_requires='>=3.6',
29
+ )