diff --git a/mps_youtube/commands/misc.py b/mps_youtube/commands/misc.py index 47749480..5c263960 100644 --- a/mps_youtube/commands/misc.py +++ b/mps_youtube/commands/misc.py @@ -109,7 +109,7 @@ def fetch_comments(item): for n, com in enumerate(coms, 1): snippet = com.get('snippet', {}) poster = snippet.get('authorDisplayName') - _, shortdate = util.yt_datetime(snippet.get('publishedAt', '')) + shortdate = util.yt_datetime(snippet.get('publishedAt', ''))[1] text = snippet.get('textDisplay', '') cid = ("%s/%s" % (n, len(coms))) commentstext += ("%s %-35s %s\n" % (cid, c.c("g", poster), shortdate)) diff --git a/mps_youtube/commands/search.py b/mps_youtube/commands/search.py index 3a10c262..0c6dbd8e 100644 --- a/mps_youtube/commands/search.py +++ b/mps_youtube/commands/search.py @@ -406,6 +406,7 @@ def get_tracks_from_json(jsons): #XXX this is a very poor attempt to calculate a rating value rating = 5.*likes/(likes+dislikes) if (likes+dislikes) > 0 else 0 category = snippet.get('categoryId') + publisheddatetime = util.yt_datetime(snippet.get('publishedAt', '')) # cache video information in custom global variable store g.meta[ytid] = dict( @@ -420,7 +421,8 @@ def get_tracks_from_json(jsons): uploaderName=snippet.get('channelTitle'), category=category, aspect="custom", #XXX - uploaded=util.yt_datetime(snippet.get('publishedAt', ''))[1], + uploaded=publisheddatetime[1], + uploadedTime=publisheddatetime[2], likes=str(num_repr(likes)), dislikes=str(num_repr(dislikes)), commentCount=str(num_repr(int(stats.get('commentCount', 0)))), diff --git a/mps_youtube/content.py b/mps_youtube/content.py index a40d8824..2fee6785 100644 --- a/mps_youtube/content.py +++ b/mps_youtube/content.py @@ -84,14 +84,14 @@ def generate_songlist_display(song=False, zeromsg=None): user_columns = _get_user_columns() if have_meta else [] maxlength = max(x.length for x in g.model) lengthsize = 8 if maxlength > 35999 else 7 - lengthsize = 5 if maxlength < 6000 else lengthsize + lengthsize = 6 if maxlength < 6000 else lengthsize reserved = 9 + lengthsize + len(user_columns) cw = getxy().width cw -= 1 title_size = cw - sum(1 + x['size'] for x in user_columns) - reserved before = [{"name": "idx", "size": 3, "heading": "Num"}, {"name": "title", "size": title_size, "heading": "Title"}] - after = [{"name": "length", "size": lengthsize, "heading": "Time"}] + after = [{"name": "length", "size": lengthsize, "heading": "Length"}] columns = before + user_columns + after for n, column in enumerate(columns): @@ -167,6 +167,7 @@ def _get_user_columns(): "rating": dict(name="rating", size=4, heading="Rtng"), "comments": dict(name="commentCount", size=4, heading="Comm"), "date": dict(name="uploaded", size=8, heading="Date"), + "time": dict(name="uploadedTime", size=11, heading="Time"), "user": dict(name="uploaderName", size=10, heading="User"), "likes": dict(name="likes", size=4, heading="Like"), "dislikes": dict(name="dislikes", size=4, heading="Dslk"), diff --git a/mps_youtube/helptext.py b/mps_youtube/helptext.py index 5c326714..2296d8ab 100644 --- a/mps_youtube/helptext.py +++ b/mps_youtube/helptext.py @@ -193,7 +193,7 @@ def helptext(): {2}set all default{1} - restore default settings {2}set checkupdate true|false{1} - check for updates on exit {2}set columns {1} - select extra displayed fields in search results: - (valid: views comments rating date user likes dislikes category) + (valid: views comments rating date time user likes dislikes category) {2}set ddir {1} - set where downloads are saved {2}set download_command {1} - type {2}help dl-command{1} for info {2}set encoder {1} - set encoding preset for downloaded files diff --git a/mps_youtube/util.py b/mps_youtube/util.py index a4562b5c..9f59e856 100644 --- a/mps_youtube/util.py +++ b/mps_youtube/util.py @@ -307,12 +307,13 @@ def real_len(u, alt=False): def yt_datetime(yt_date_time): - """ Return a time object and locale formated date string. """ + """ Return a time object, locale formated date string and locale formatted time string. """ time_obj = time.strptime(yt_date_time, "%Y-%m-%dT%H:%M:%S.%fZ") locale_date = time.strftime("%x", time_obj) + locale_time = time.strftime("%X", time_obj) # strip first two digits of four digit year short_date = re.sub(r"(\d\d\D\d\d\D)20(\d\d)$", r"\1\2", locale_date) - return time_obj, short_date + return time_obj, short_date, locale_time def parse_multi(choice, end=None):