diff --git a/pyproject.toml b/pyproject.toml index 846cdad..84adb44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,43 +1,42 @@ [build-system] requires = ["setuptools", "wheel"] -[project] -name = "generss" -dynamic = ["version"] - authors = [ {name = "Amine Sehili", email = "amine.sehili@gmail.com"}, ] + +[project] +name = "generss" +dynamic = ["version"] description = "Generate RSS feeds from media files in a directory" readme = {file = "README.md", content-type = "text/markdown"} requires-python = ">=3.4" keywords = ["RSS", "podcast"] license = {text = "MIT License"} classifiers=[ - "Development Status :: 3 - Alpha", - "Environment :: Console", - "Intended Audience :: Developers", - "Intended Audience :: End Users/Desktop", - "Intended Audience :: Information Technology", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Topic :: Communications :: File Sharing", - "Topic :: Utilities", + "Development Status :: 3 - Alpha", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: End Users/Desktop", + "Intended Audience :: Information Technology", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Communications :: File Sharing", + "Topic :: Utilities", ] dependencies = ["mutagen==1.47.0", "eyed3==0.9.7"] - [project.scripts] genRSS = "genRSS:main" -[tool.setuptools.dynamic] -version = {attr = "genRSS.__version__"} +[tool.setuptools.dynamic] +version = {attr = "genRSS.__version__"} \ No newline at end of file diff --git a/src/genRSS.py b/src/genRSS/__init__.py similarity index 91% rename from src/genRSS.py rename to src/genRSS/__init__.py index 514f30b..69533ea 100644 --- a/src/genRSS.py +++ b/src/genRSS/__init__.py @@ -4,10 +4,10 @@ genRSS -- generate an RSS 2.0 feed from media files in a directory. @author: Amine SEHILI -@copyright: 2014-2023 Amine SEHILI +@copyright: 2014-2024 Amine SEHILI @license: MIT @contact: amine.sehili gmail.com -@deffield updated: September 13th 2023 +@deffield updated: December 1st 2024 """ import sys @@ -19,12 +19,12 @@ import argparse from xml.sax import saxutils -import util +from genRSS import util __all__ = [] -__version__ = "0.3.0" +__version__ = "0.3.1" __date__ = "2014-11-01" -__updated__ = "2023-09-13" +__updated__ = "2024-12-01" DEBUG = 0 TESTRUN = 0 @@ -44,9 +44,7 @@ def main(argv=None): description=program_longdesc, formatter_class=argparse.RawTextHelpFormatter, ) - parser.add_argument( - "--version", "-v", action="version", version=__version__ - ) + parser.add_argument("--version", "-v", action="version", version=__version__) parser.add_argument( "-d", "--dirname", @@ -184,9 +182,9 @@ def main(argv=None): if host[-1] != "/": host += "/" - if not host.lower().startswith( - "http://" - ) and not host.lower().startswith("https://"): + if not host.lower().startswith("http://") and not host.lower().startswith( + "https://" + ): host = "http://" + host title = "" @@ -210,12 +208,13 @@ def main(argv=None): if opts.extensions is not None: opts.extensions = [e for e in opts.extensions.split(",") if e != ""] file_names = util.get_files( - dirname, extensions=opts.extensions, recursive=opts.recursive, followlinks=opts.followlinks + dirname, + extensions=opts.extensions, + recursive=opts.recursive, + followlinks=opts.followlinks, ) if len(file_names) == 0: - sys.stderr.write( - "No media files on directory '%s'\n" % (opts.dirname) - ) + sys.stderr.write("No media files on directory '%s'\n" % (opts.dirname)) sys.exit(0) if opts.sort_creation: @@ -223,11 +222,9 @@ def main(argv=None): # get files date of creation in seconds pub_dates = [os.path.getmtime(f) for f in file_names] # most feed readers will use pubDate to sort items even if they are - # not sorted in the output file for readability, we also sort fileNames + # not sorted in the output file for readability, we also sort file_names # according to pubDates in the feed. - sorted_files = sorted( - zip(file_names, pub_dates), key=lambda f: -f[1] - ) + sorted_files = sorted(zip(file_names, pub_dates), key=lambda f: -f[1]) else: # In order to have feed items sorted by name, we give them artificial @@ -272,9 +269,7 @@ def main(argv=None): ) ) outfp.write(" {0}\n".format(saxutils.escape(title))) - outfp.write( - " {0}\n".format(description) - ) + outfp.write(" {0}\n".format(description)) outfp.write(" {0}\n".format(link)) if opts.image is not None: @@ -287,9 +282,7 @@ def main(argv=None): outfp.write(" \n") outfp.write(" {0}\n".format(imgurl)) - outfp.write( - " {0}\n".format(saxutils.escape(title)) - ) + outfp.write(" {0}\n".format(saxutils.escape(title))) outfp.write(" {0}\n".format(link)) outfp.write(" \n") outfp.write(f" \n") diff --git a/src/util.py b/src/genRSS/util.py similarity index 97% rename from src/util.py rename to src/genRSS/util.py index 76c80c9..3f2a58d 100644 --- a/src/util.py +++ b/src/genRSS/util.py @@ -217,7 +217,7 @@ def get_title(filename, use_metadata=False): title (str): Item title. Examples: - >>> media_dir = os.path.join("test", "media") + >>> media_dir = os.path.join("../../test", "media") >>> flac_file = os.path.join(media_dir, 'flac_with_tags.flac') >>> mp3_file = os.path.join(media_dir, 'mp3_with_tags.mp3') @@ -296,13 +296,13 @@ def get_duration(filename): duration (int): The duration as the number of seconds or None. Examples: - >>> get_duration("test/silence/silence_7.14_seconds.ogg") + >>> get_duration("../../test/silence/silence_7.14_seconds.ogg") 7 - >>> get_duration("test/silence/silence_2.5_seconds.wav") + >>> get_duration("../../test/silence/silence_2.5_seconds.wav") 2 - >>> get_duration("test/media/flac_with_tags.flac") # empty file + >>> get_duration("../../test/media/flac_with_tags.flac") # empty file 0 - >>> get_duration("test/media/1.mp3") is None # invalid file + >>> get_duration("../../test/media/1.mp3") is None # invalid file True """ duration = get_duration_mutagen(filename) @@ -487,7 +487,7 @@ def get_files(dirname, extensions=None, recursive=False, followlinks=False): Examples: >>> import os - >>> media_dir = os.path.join("test", "media") + >>> media_dir = os.path.join("../../test", "media") >>> files = ['1.mp3', '1.mp4', '1.ogg', '2.MP3', 'flac_with_tags.flac', 'mp3_with_tags.mp3'] >>> expected = [os.path.join(media_dir, f) for f in files] >>> get_files(media_dir) == expected