diff --git a/.gitignore b/.gitignore index 4e8c22a..8048d1f 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ bin var tags .env +env/ +.idea/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..c5d438b --- /dev/null +++ b/README.md @@ -0,0 +1,117 @@ +yewtube +=========== +![](https://img.shields.io/pypi/v/mps-youtube.svg) ![](https://img.shields.io/pypi/dm/mps-youtube.svg) ![](https://img.shields.io/pypi/wheel/mps-youtube.svg) + +Installation +------------ +1. It is recommended that you first Uninstall previous installations of `mps-youtube` +1. Install `pipx` using `pip` or using your favorite Linux Package + Manager. You can find instructions to do so [here.](https://pypa.github.io/pipx/installation/) +1. Install `yewtube` using + `pipx install git+https://github.com/iamtalhaasghar/yewtube.git` +1. Resolve `youtube-dl` dependency using + `pipx inject yewtube youtube-dl` +1. That's it. + +Features +-------- + +- Search and play audio/video from YouTube +- Search tracks of albums by album title +- Search and import YouTube playlists +- Create and save local playlists +- Download audio/video +- Convert to mp3 & other formats (requires ffmpeg or avconv) +- View video comments +- Works with Python 3.x +- Works with Windows, Linux and Mac OS X +- Requires mplayer or mpv + +This project is based on [mps-youtube](https://github.com/mps-youtube/mps-youtube) and mps-youtube is based on [mps](https://web.archive.org/web/20180429034221/https://github.com/np1/mps), a terminal based program to search, stream and download music. This +implementation uses YouTube as a source of content and can play and +download video as well as audio. The [pafy](https://github.com/mps-youtube/pafy) library handles interfacing with YouTube. + +[FAQ / Troubleshooting common issues](https://github.com/mps-youtube/mps-youtube/wiki/Troubleshooting) + +Screenshots +----------- + +Search: +![](http://mps-youtube.github.io/mps-youtube/std-search.png) + +A standard search is performed by entering `/` followed by search terms. + +You can play all of the search results by giving `1-` as input + +Repeating song/songs can be done with `song_number[loop]`, for example: +`1[3]` or `4-6[2]` + +Local Playlists: +![](http://mps-youtube.github.io/mps-youtube/local-playlist.png) + +Search result items can easily be stored in local playlists. + +YouTube Playlists: +![](http://mps-youtube.github.io/mps-youtube/playlist-search.png) + +YouTube playlists can be searched and played or saved as local +playlists. + +A playlist search is performed by `//` followed by search term. + +Download: +![](http://mps-youtube.github.io/mps-youtube/download.png) + +Content can be downloaded in various formats and resolutions. + +Comments: +![](http://mps-youtube.github.io/mps-youtube/comments.png) + +A basic comments browser is available to view YouTube user comments. + +Music Album Matching: + +![](http://mps-youtube.github.io/mps-youtube/album-1.png) + +![](http://mps-youtube.github.io/mps-youtube/album-2.png) + +An album title can be specified and yewtube will attempt to find +matches for each track of the album, based on title and duration. Type +`help search` for more info. + +Customisation: + +![](http://mps-youtube.github.io/mps-youtube/customisation2.png) + +Search results can be customised to display additional fields and +ordered by various criteria. + +This configuration was set up using the following commands +``` +set order views +set columns user:14 date comments rating likes dislikes category:9 views +``` + +Type `help config` for help on configuration options + +Upgrading +--------- + +Upgrade pip installation:: + + pipx upgrade yewtube + +Usage +----- + +yewtube is run on the command line using the command:: + + `yt` + +Enter `h` from within the program for help. + +How to Contribute +----------------- + +Contributions are welcomed! However, please check out the [contribution page](https://github.com/iamtalhaasghar/yewtube/blob/develop/CONTRIBUTING.md) before making a contribution. + diff --git a/VERSION b/VERSION index 92ed432..c6b0824 100644 --- a/VERSION +++ b/VERSION @@ -1,4 +1,4 @@ # This file is used by clients to check for updates -version 0.2.8 +version 1.0.0 diff --git a/mps_youtube/__init__.py b/mps_youtube/__init__.py index 7ed57d6..b1e8196 100644 --- a/mps_youtube/__init__.py +++ b/mps_youtube/__init__.py @@ -1,8 +1,8 @@ -__version__ = "0.2.8" -__notes__ = "released 17 February 2018" -__author__ = "np1" +__version__ = "1.0.0" +__notes__ = "released 14 October 2021" +__author__ = "iamtalhaasghar" __license__ = "GPLv3" -__url__ = "https://github.com/mps-youtube/mps-youtube" +__url__ = "https://github.com/iamtalhaasghar/yewtube" from . import init init.init() diff --git a/mps_youtube/cache.py b/mps_youtube/cache.py index 9d512a7..fee64fd 100644 --- a/mps_youtube/cache.py +++ b/mps_youtube/cache.py @@ -20,7 +20,7 @@ def load(): with open(g.CACHEFILE, "rb") as cf: cached = pickle.load(cf) - # Note: will be none for mpsyt 0.2.5 or earlier + # Note: will be none for yewtube 0.2.5 or earlier version = cached.get('version') if 'streams' in cached: diff --git a/mps_youtube/commands/album_search.py b/mps_youtube/commands/album_search.py index 2b409d4..8867e38 100644 --- a/mps_youtube/commands/album_search.py +++ b/mps_youtube/commands/album_search.py @@ -24,7 +24,7 @@ def show_message(message, col=c.r, update=False): def _do_query(url, query, err='query failed', report=False): - """ Perform http request using mpsyt user agent header. + """ Perform http request using yewtube user agent header. if report is True, return whether response is from memo diff --git a/mps_youtube/content.py b/mps_youtube/content.py index 0bedbdb..a9859f6 100644 --- a/mps_youtube/content.py +++ b/mps_youtube/content.py @@ -206,12 +206,16 @@ def _get_user_columns(): def logo(col=None, version=""): """ Return text logo. """ col = col if col else random.choice((c.g, c.r, c.y, c.b, c.p, c.w)) - logo_txt = r""" _ _ - _ __ ___ _ __ ___ _ _ ___ _ _| |_ _ _| |__ ___ -| '_ ` _ \| '_ \/ __|_____| | | |/ _ \| | | | __| | | | '_ \ / _ \ -| | | | | | |_) \__ \_____| |_| | (_) | |_| | |_| |_| | |_) | __/ -|_| |_| |_| .__/|___/ \__, |\___/ \__,_|\__|\__,_|_.__/ \___| - |_| |___/""" + logo_txt = r""" _ _ + | | | | + _ _ _____ _| |_ _ _| |__ ___ + | | | |/ _ \ \ /\ / / __| | | | '_ \ / _ \ + | |_| | __/\ V V /| |_| |_| | |_) | __/ + \__, |\___| \_/\_/ \__|\__,_|_.__/ \___| + __/ | + |___/ + """ + version = " v" + version if version else "" logo_txt = col + logo_txt + c.w + version lines = logo_txt.split("\n") diff --git a/mps_youtube/g.py b/mps_youtube/g.py index 9f66c5b..3949e46 100644 --- a/mps_youtube/g.py +++ b/mps_youtube/g.py @@ -94,9 +94,9 @@ argument_commands = [] commands = [] text = { - "exitmsg": ("*mps-youtube - *https://github.com/mps-youtube/mps-youtube*" + "exitmsg": ("*yewtube - https://github.com/iamtalhaasghar/yewtube is a fork of\nmps-youtube - *https://github.com/mps-youtube/mps-youtube*" "\nReleased under the GPLv3 license\n" - "(c) 2014, 2015 np1 and contributors*\n"""), + "(c) 2021 iamtalhaashgar\n(c) 2014, 2015 np1 and contributors*\n"""), "exitmsg_": (c.r, c.b, c.r, c.w), # Error / Warning messages diff --git a/mps_youtube/helptext.py b/mps_youtube/helptext.py index f0ae954..4f9ae13 100644 --- a/mps_youtube/helptext.py +++ b/mps_youtube/helptext.py @@ -27,7 +27,7 @@ def helptext(): {2}u {1} - show videos uploaded by uploader of video {2}x {1} - copy item url to clipboard (requires pyperclip) - {2}q{1}, {2}quit{1} - exit mpsyt + {2}q{1}, {2}quit{1} - exit yewtube """.format(c.ul, c.w, c.y)), ("search", "Searching and Retrieving", """ {0}Searching and Retrieving{1} @@ -175,7 +175,7 @@ def helptext(): ("history", "Accessing Local History", """ {0}Accessing Local History{1} - Access songs that have been played within mpsyt + Access songs that have been played within yewtube {2}history{1} - displays a list of songs contained in history {2}history clear{1} - clears the song history @@ -186,20 +186,20 @@ def helptext(): ("invoke", "Invocation Parameters", """ {0}Invocation{1} - All mpsyt commands can be entered from the command line. For example; + All yewtube commands can be entered from the command line. For example; - {2}mpsyt dlurl {1} to download a YouTube video by url or id - {2}mpsyt playurl {1} to play a YouTube video by url or id - {2}mpsyt /mozart{1} to search - {2}mpsyt //best songs of 2010{1} for a playlist search - {2}mpsyt play {1} to play a saved playlist - {2}mpsyt ls{1} to list saved playlists + {2}yt dlurl {1} to download a YouTube video by url or id + {2}yt playurl {1} to play a YouTube video by url or id + {2}yt /mozart{1} to search + {2}yt //best songs of 2010{1} for a playlist search + {2}yt play {1} to play a saved playlist + {2}yt ls{1} to list saved playlists For further automation, a series of commands can be entered separated by commas (,). E.g., - {2}mpsyt open 1, 2-4{1} - play items 2-4 of first saved playlist - {2}mpsyt //the doors, 1, all -a{1} - open YouTube playlist and play audio + {2}yt open 1, 2-4{1} - play items 2-4 of first saved playlist + {2}yt //the doors, 1, all -a{1} - open YouTube playlist and play audio If you need to enter an actual comma on the command line, use {2},,{1} instead. """.format(c.ul, c.w, c.y)), @@ -328,7 +328,7 @@ def get_help(choice): "encode": ("encoding transcoding transcode wma mp3 format " "encode encoder".split()), - "invoke": "command commands mpsyt invocation".split(), + "invoke": "command commands yt invocation".split(), "search": ("user userpl pl pls r n p url album " "editing result results related remove swop mkp --description".split()), diff --git a/mps_youtube/init.py b/mps_youtube/init.py index 9c18929..0b7e998 100644 --- a/mps_youtube/init.py +++ b/mps_youtube/init.py @@ -268,7 +268,7 @@ def _get_version_info(): import youtube_dl youtube_dl_version = youtube_dl.version.__version__ - out = "mpsyt version : " + __version__ + out = "yewtube version : " + __version__ out += "\n notes : " + __notes__ out += "\npafy version : " + pafy_version if youtube_dl_version: diff --git a/mps_youtube/main.py b/mps_youtube/main.py index 3d0d0d7..7b33483 100644 --- a/mps_youtube/main.py +++ b/mps_youtube/main.py @@ -112,7 +112,7 @@ def prompt_for_exit(): def main(): """ Main control loop. """ if config.SET_TITLE.get: - util.set_window_title("mpsyt") + util.set_window_title("yewtube") if not g.command_line: g.content = content.logo(col=c.g, version=__version__) + "\n\n" diff --git a/mps_youtube/player.py b/mps_youtube/player.py index a96f4cf..41c4ad5 100644 --- a/mps_youtube/player.py +++ b/mps_youtube/player.py @@ -64,7 +64,7 @@ class BasePlayer: override=self.override) if config.SET_TITLE.get: - util.set_window_title(self.song.title + " - mpsyt") + util.set_window_title(self.song.title + " - yewtube") self.softrepeat = repeat and len(self.songlist) == 1 @@ -92,7 +92,7 @@ class BasePlayer: pass if config.SET_TITLE.get: - util.set_window_title("mpsyt") + util.set_window_title("yewtube") if self.song_no == -1: self.song_no = len(songlist) - 1 if repeat else 0 @@ -306,7 +306,7 @@ class CmdPlayer(BasePlayer): g.mprisctl.send(('stop', True)) if self.p and self.p.poll() is None: - self.p.terminate() # make sure to kill mplayer if mpsyt crashes + self.p.terminate() # make sure to kill mplayer if yewtube crashes self.clean_up() diff --git a/mps_youtube/players/mplayer.py b/mps_youtube/players/mplayer.py index af70618..887d740 100644 --- a/mps_youtube/players/mplayer.py +++ b/mps_youtube/players/mplayer.py @@ -192,7 +192,7 @@ class mplayer(CmdPlayer): def _get_input_file(): """ Check for existence of custom input file. - Return file name of temp input file with mpsyt mappings included + Return file name of temp input file with yewtube mappings included """ confpath = conf = '' diff --git a/mps_youtube/players/mpv.py b/mps_youtube/players/mpv.py index a9d10be..6f488c1 100644 --- a/mps_youtube/players/mpv.py +++ b/mps_youtube/players/mpv.py @@ -275,7 +275,7 @@ class mpv(CmdPlayer): def _get_input_file(): """ Check for existence of custom input file. - Return file name of temp input file with mpsyt mappings included + Return file name of temp input file with yewtube mappings included """ confpath = conf = '' diff --git a/mps_youtube/playlists.py b/mps_youtube/playlists.py index dab9403..0a39338 100644 --- a/mps_youtube/playlists.py +++ b/mps_youtube/playlists.py @@ -160,7 +160,7 @@ def _convert_playlist_to_m3u(): os.mkdir(g.PLFOLDER) save() - screen.msgexit("Updated playlist file. Please restart mpsyt", 1) + screen.msgexit("Updated playlist file. Please restart yewtube", 1) except EOFError: screen.msgexit("Error opening playlists from %s" % g.PLFILE, 1) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..18bc1fa --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +pafy +youtube_dl \ No newline at end of file diff --git a/setup.py b/setup.py index 4d200d8..075c00e 100755 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ #!/usr/bin/python3 -""" setup.py for mps-youtube. +""" setup.py for yewtube. -https://np1.github.com/mps-youtube +https://github.com/iamtalhaasghar/yewtube python setup.py sdist bdist_wheel """ @@ -11,23 +11,23 @@ import sys import os if sys.version_info < (3,0): - sys.exit("Mps-youtube requires python 3.") + sys.exit("yewtube requires python 3.") from setuptools import setup -VERSION = "0.2.8" +VERSION = "1.0.0" options = dict( - name="mps-youtube", + name="yewtube", version=VERSION, description="Terminal based YouTube player and downloader", keywords=["video", "music", "audio", "youtube", "stream", "download"], - author="np1", - author_email="np1nagev@gmail.com", - url="https://github.com/mps-youtube/mps-youtube", - download_url="https://github.com/mps-youtube/mps-youtube/archive/v%s.tar.gz" % VERSION, + author="talha_programmer", + author_email="talhaasghar.contact@simplelogin.fr", + url="https://github.com/iamtalhaasghar/yewtube", + download_url="https://github.com/iamtalhaasghar/yewtube/releases", packages=['mps_youtube', 'mps_youtube.commands', 'mps_youtube.listview', 'mps_youtube.players'], - entry_points={'console_scripts': ['mpsyt = mps_youtube:main.main']}, + entry_points={'console_scripts': ['yt = mps_youtube:main.main']}, install_requires=['pafy >= 0.3.82, != 0.4.0, != 0.4.1, != 0.4.2'], classifiers=[ "Topic :: Utilities", @@ -62,20 +62,20 @@ options = dict( "bundle_files": 1 } }, - package_data={"": ["LICENSE", "README.rst", "CHANGELOG"]}, - long_description=open("README.rst").read() + package_data={"": ["LICENSE", "README.md", "CHANGELOG"]}, + long_description=open("README.md").read() ) if sys.platform.startswith('linux'): # Install desktop file. Required for mpris on Ubuntu - options['data_files'] = [('share/applications/', ['mps-youtube.desktop'])] + options['data_files'] = [('share/applications/', ['yewtube.desktop'])] if os.name == "nt": try: import py2exe # Only setting these when py2exe imports successfully prevents warnings # in easy_install - options['console'] = ['mpsyt'] + options['console'] = ['yt'] options['zipfile'] = None except ImportError: pass diff --git a/mps-youtube.desktop b/yewtube.desktop similarity index 86% rename from mps-youtube.desktop rename to yewtube.desktop index 886e3e0..2ada9b1 100644 --- a/mps-youtube.desktop +++ b/yewtube.desktop @@ -1,8 +1,8 @@ [Desktop Entry] -Name=mps-youtube +Name=yewtube GenericName=Music Player Keywords=Audio;Song;Podcast;Playlist;youtube.com; -Exec=mpsyt %U +Exec=yt %U Terminal=true Icon=terminal Type=Application diff --git a/mpsyt b/yt old mode 100755 new mode 100644 similarity index 100% rename from mpsyt rename to yt