Get exact time of a posted YouTube comment - time

I didn't found any info on that.
For example, when you look at YouTube comments there is a timestamp next to it saying "1 hours ago".
Now is "1 hours ago" not a precise time indication. It could be anything from 1h00min to 1h59min.
So is it possible to get the excat time of a posted YouTube comment, like 'Wednesday 18, 9:36'?
Edit
Here is my solution to get both the exact and modified time:
https://www.googleapis.com/youtube/v3/comments?part=snippet&fields=items(snippet/publishedAt,snippet/updatedAt)&id={COMMENT_ID}&key={YOUR_API_KEY}

Yes. The API returns the full datetimes, as you can see in the json here:
"publishedAt": datetime,
"updatedAt": datetime
https://developers.google.com/youtube/v3/docs/comments#resource

Related

Parse hours from string with space delimiter

I have file strings that contain dates in their heading, stuff such as 2017-03-06 092328 - iPhone - Music Show - street performance, while walking the dog.m4a
I would like to parse the date our of this string, because I need to print it in a podcast friendly format.
I'm able to parse out the date, but for some reason the time component refuses to be parsed out :)
Date.strptime("2017-03-06 092328", "%Y-%m-%d %H%M%S").strftime(%Y-%m-%d %H%M%S)
Expected output:
"2017-03-06 092328"
Actual output
"2017-03-06 000000"
Your problem is that Date is (what a surprise!) a date, as in, "Not a time, just a date".
require 'time'
Time.strptime("2017-03-06 092328", "%Y-%m-%d %H%M%S").strftime("%Y-%m-%d %H:%M:%S")
#=> "2017-03-06 09:23:28"
To be fair :
the documentation of Time#strptime mentions that it's based on Date#strptime
Date._parse("2017-03-06 09:23:28") will happily return {:hour=>9, :min=>23, :sec=>28, :year=>2017, :mon=>3, :mday=>6}
If you find it confusing that a Time object has a date and a time but that Date just has a date, you could use DateTime.

Kendo DateTimePicker, after parsing the Date the Year is Incorrect

Good Afternoon Fellow Code Monkey's
I'm new to StackOverflow, and Kendo UI programming. My problem is as follows. When trying to parse the date, and everything seems to work correctly until I get to the year portion.
here is my Javascript Code
$('#datepicker').kendoDatePicker({
format: 'MM dd yyyy',
parseFormats:['M/d/yy', 'MM/d/yy', 'MM/dd/yy', 'M/dd/yy', 'M/d/yyyy', 'MM/d/yyyy', 'MM/dd/yyyy','M/dd/yyyy','Mdyy','MMdyy', 'MMddyy', 'Mdyyyy', 'Mddyyyy', 'MMddyyyy', 'M-d-yy', 'MM-d-yy', 'MM-dd-yy', 'M-dd-yy', 'M-d-yyyy', 'MM-d-yyyy', 'MM-dd-yyyy', 'M-dd-yyyy']
});
Basically I want the user to be able to type the date into the Datepicker in any format, from 05052012 to 5/5/2012, etc and then the box formats. The above code for instance when entering "05052012" returns in the box 05 05 2020. Is there something wrong with how I have the year set up?
Thanks in advance,
SithApprentice
I think I have it figured out, seems sort of silly now. Apparently it has to do with the order in which I'm passing the formats with which I will be paresing. those with yy must come at the end, and those with yyyy must come at the beginning. I really wishTelerik mentioned this in their API Reference section for the date picker. From theier examples they make it seem like the order does not matter.

cucumber capybara testing date picker selects wrong day

I am trying to write a cucumber test for a page that includes a datepicker. I swear this was working yesterday, but not so much today.
Then(/^select date (\d+) day(?:s|) prior to today$/) do |n|
day=Date.today-(n.to_i)
target = Date.strptime("#{day}",'%Y-%m-%d')
target_month_year = target.strftime('%B %Y')
selected_month_year = (find('.datepicker-switch').native.text)
unless target_month_year == selected_month_year
find('.prev').click
sleep 1
end
find('.day', :text => "#{day.day}", match: :prefer_exact).click
sleep 2
end
Then I have a separate test that checks that the correct date is presented after selection. I have verified that day.day is giving me the correct result by including a puts(day.day), as well as all the other variables. I think the problem is a matching issue, today's date is 04/24/2015 and I selecting 15 days prior. So the datepicker that displays the month and year above and allows you to select previous or next, then the days shown are according to how many days in that particular month. and a few day before and after. the days for the previous month are class="old day" and the ones for the month displayed are class="day" and for the next month class="new day". so the month I want is april and the day is the ninth. it keeps selecting the 29th of march. which is the first day listed on the page that contains a "9". but the class is wrong, since I want "day" not "old day" and the day is wrong because I want "9" not "29" I even put in a :prefer_exact because that has fixed matching the wrong element in the past for me.
Not sure what to try next. Any advice greatly appreciated.
cucumber 1.3.10
capybara 2.4.1
ruby 1.9.3p551
Ideally, don't select by text if you can avoid it.
But in this case try using a regex instead of just plain text.
find('.day', :text => Regexp.new("^#{day.day}$"), match: :prefer_exact).click
There's a little related reading at the end of this (currently unimplemented) issue: https://github.com/jnicklas/capybara/issues/1256

Why is my YouTube API Insight report query 404ing?

I have a Ruby script which downloads YouTube Insight reports for specific videos within specific date ranges. It authorizes with ClientLogin, retrieves <entry> XML data for a video, and extracts from that data a URL which points to a CSV report:
http://insight.youtube.com/video-analytics/csvreports
?query={VIDEO_ID}
&type=v
&starttime=1315353600000
&endtime=1317772800000
&user_starttime=1317168000000
&user_endtime=1317772800000
&region=world
&token={API_TOKEN}
&hl=en_US
The above URL works. However, I want a report for a specific date range, not the default range provided.
An Insight report query's requested date range is set in the user_starttime and user_endtime params. (In the above default case, it's 2011-09-27 through 2011-10-04.) The YouTube API docs say that you can specify your own date range (covering a span of up to 28 days) by substituting timestamps (in milliseconds) that represent the dates you want.
So, why does the following query 404?
http://insight.youtube.com/video-analytics/csvreports
?query={VIDEO_ID}
&type=v
&starttime=1315353600000
&endtime=1317772800000
&user_starttime=1307937600000
&user_endtime=1308110400000
&region=world
&token={API_TOKEN}
&hl=en_US
The date range looks OK:
ruby > Time.at 1307937600
=> 2011-06-13 00:00:00 -0400
ruby > Time.at 1308110400
=> 2011-06-15 00:00:00 -0400
The fact that the "default" URL works indicates that I must be doing something wrong with these date values, but I can't figure out what. What am I overlooking?
UPDATE 2 -- Nov. 4, 2011:
There has recently been a change to the YouTube Data API Protocol for Insight data, and the answer below is no longer accurate.
YouTube now permits date ranges of up to 31 days for a single Insight report query, and they now allow requests pertaining to dates going back to March 1, 2009. The docs now say:
You can adjust the date range for which a report contains data
to a period of up to 31 days beginning no earlier than March 1, 2009.
This is excellent news. (Leaving the below for posterity.)
I believe I've figured out why the above Insight report query with the custom date range is 404ing. I was able to retrieve a report with a custom date range like this:
http://insight.youtube.com/video-analytics/csvreports
?query={VIDEO_ID}
&type=v
&starttime=1315353600000
&endtime=1317772800000
&user_starttime=1315627200000
&user_endtime=1315972800000
&region=world
&token={API_TOKEN}
&hl=en_US
What's the difference between this (good) URL and the previous (bad) URL in my question above? Well, my custom date range here, specified in the user_starttime and user_endtime parameters both fall within the range set by YouTube in the starttime and endtime params.
In other words, starttime and endtime seem to represent the outer bounds of any user-specified custom date range possible through these types of requests.
So, when the YouTube API docs say:
You can adjust the date range for which a report contains data to a period of up to 28 days
What they mean, I suppose, is:
Your date range may not span more than 28 days ... AND ALSO ...
Your date range may not fall outside of a date range going back 28 days from the most recent date on which reports are currently available, which we tell you through the starttime and endtime parameters.
UPDATE:
In this thread, a YouTube API Team member says:
You should consider the starttime value the absolute earliest supported start date and endtime the absolute latest supported end date. If you try to set user_starttime to something earlier than starttime then you're going to ask for data that dates back more than 28 days, and that data isn't available.
This exact text should be in the documentation.

Yahoo Pipes: How to convert string from Fetch Page into date for RSS feed?

I am trying to create a rss feed from a web page. I am able to get the data to create the title, but I am trying to get the date updated correctly. There is a string on the page, that tells what time of day the news was reported, such as "Time of Report: 1pm". So how can I get the "1pm" and convert that to a date string that contains the current date, with this time?
Thanks,
CP
The Pipes "Date Builder" module is surprisingly powerful.
You can actually feed it a string like "1pm" and it will return:
hour21
timezoneUTC
second0
month1
minute0
utime1264021200
day20
day_of_week3
year2010
The date is relative to when you run it - in this case it assumes "1pm Today". The result is "hour21" in UTC because it parsed in Yahoo's time-zone. So if you need something specific, use the "Sting Builder" to append the time-zone. For example "1pm GMT" gives:
hour13
timezoneUTC
second0
month1
minute0
utime1263992400
day20
day_of_week3
year2010
Obviously you may run into issues if your pipe runs after a date change - an "11pm" entry could easily be read the following morning, leading to inaccurate results.

Resources