Updated Easy::Attachment.
Moved Metadata into Attachment::meta.
This commit is contained in:
parent
6ae56a05b4
commit
8fe607d43e
|
@ -32,21 +32,6 @@ bool Attachment::valid() const
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
double Attachment::aspect() const
|
|
||||||
{
|
|
||||||
return get_double("meta.original.aspect");
|
|
||||||
}
|
|
||||||
|
|
||||||
double Attachment::aspect_small() const
|
|
||||||
{
|
|
||||||
return get_double("meta.small.aspect");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t Attachment::bitrate() const
|
|
||||||
{
|
|
||||||
return get_uint64("meta.original.bitrate");
|
|
||||||
}
|
|
||||||
|
|
||||||
const string Attachment::description() const
|
const string Attachment::description() const
|
||||||
{
|
{
|
||||||
return get_string("description");
|
return get_string("description");
|
||||||
|
@ -58,13 +43,6 @@ Attachment Attachment::description(const string &description)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::chrono::duration<double> Attachment::duration() const
|
|
||||||
{
|
|
||||||
const double sec = get_double("meta.original.duration");
|
|
||||||
|
|
||||||
return std::chrono::duration<double>(sec);
|
|
||||||
}
|
|
||||||
|
|
||||||
const string Attachment::file() const
|
const string Attachment::file() const
|
||||||
{
|
{
|
||||||
return get_string("file");
|
return get_string("file");
|
||||||
|
@ -100,40 +78,16 @@ Attachment Attachment::focus(const std::array<double, 2> &focus)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Attachment::framerate() const
|
|
||||||
{
|
|
||||||
string strframes = get_string("meta.original.frame_rate");
|
|
||||||
|
|
||||||
if (!strframes.empty())
|
|
||||||
{
|
|
||||||
std::size_t pos = strframes.find('/');
|
|
||||||
if (pos != std::string::npos)
|
|
||||||
{
|
|
||||||
std::uint16_t frames = std::stoul(strframes.substr(0, pos));
|
|
||||||
std::uint16_t divider = std::stoul(strframes.substr(pos + 1));
|
|
||||||
|
|
||||||
return frames / divider;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t Attachment::height() const
|
|
||||||
{
|
|
||||||
return get_uint64("meta.original.height");
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t Attachment::height_small() const
|
|
||||||
{
|
|
||||||
return get_uint64("meta.small.height");
|
|
||||||
}
|
|
||||||
|
|
||||||
const string Attachment::id() const
|
const string Attachment::id() const
|
||||||
{
|
{
|
||||||
return get_string("id");
|
return get_string("id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Attachment::Meta Attachment::meta() const
|
||||||
|
{
|
||||||
|
return Meta(get("meta"));
|
||||||
|
}
|
||||||
|
|
||||||
const string Attachment::preview_url() const
|
const string Attachment::preview_url() const
|
||||||
{
|
{
|
||||||
return get_string("preview_url");
|
return get_string("preview_url");
|
||||||
|
@ -144,16 +98,6 @@ const string Attachment::remote_url() const
|
||||||
return get_string("remote_url");
|
return get_string("remote_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
const string Attachment::size() const
|
|
||||||
{
|
|
||||||
return get_string("meta.original.size");
|
|
||||||
}
|
|
||||||
|
|
||||||
const string Attachment::size_small() const
|
|
||||||
{
|
|
||||||
return get_string("meta.small.size");
|
|
||||||
}
|
|
||||||
|
|
||||||
const string Attachment::text_url() const
|
const string Attachment::text_url() const
|
||||||
{
|
{
|
||||||
return get_string("text_url");
|
return get_string("text_url");
|
||||||
|
@ -180,12 +124,78 @@ const string Attachment::url() const
|
||||||
return get_string("url");
|
return get_string("url");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Attachment::width() const
|
bool Attachment::Meta::valid() const
|
||||||
{
|
{
|
||||||
return get_uint64("meta.original.width");
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Attachment::width_small() const
|
double Attachment::Meta::aspect() const
|
||||||
{
|
{
|
||||||
return get_uint64("meta.small.width");
|
return get_double("original.aspect");
|
||||||
|
}
|
||||||
|
|
||||||
|
double Attachment::Meta::aspect_small() const
|
||||||
|
{
|
||||||
|
return get_double("small.aspect");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Attachment::Meta::bitrate() const
|
||||||
|
{
|
||||||
|
return get_uint64("original.bitrate");
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::chrono::duration<double> Attachment::Meta::duration() const
|
||||||
|
{
|
||||||
|
const double sec = get_double("original.duration");
|
||||||
|
|
||||||
|
return std::chrono::duration<double>(sec);
|
||||||
|
}
|
||||||
|
|
||||||
|
double Attachment::Meta::frame_rate() const
|
||||||
|
{
|
||||||
|
string strframes = get_string("original.frame_rate");
|
||||||
|
|
||||||
|
if (!strframes.empty())
|
||||||
|
{
|
||||||
|
std::size_t pos = strframes.find('/');
|
||||||
|
if (pos != std::string::npos)
|
||||||
|
{
|
||||||
|
std::uint16_t frames = std::stoul(strframes.substr(0, pos));
|
||||||
|
std::uint16_t divider = std::stoul(strframes.substr(pos + 1));
|
||||||
|
|
||||||
|
return frames / divider;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Attachment::Meta::height() const
|
||||||
|
{
|
||||||
|
return get_uint64("original.height");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Attachment::Meta::height_small() const
|
||||||
|
{
|
||||||
|
return get_uint64("small.height");
|
||||||
|
}
|
||||||
|
|
||||||
|
const string Attachment::Meta::size() const
|
||||||
|
{
|
||||||
|
return get_string("original.size");
|
||||||
|
}
|
||||||
|
|
||||||
|
const string Attachment::Meta::size_small() const
|
||||||
|
{
|
||||||
|
return get_string("small.size");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Attachment::Meta::width() const
|
||||||
|
{
|
||||||
|
return get_uint64("original.width");
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t Attachment::Meta::width_small() const
|
||||||
|
{
|
||||||
|
return get_uint64("small.width");
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,29 +48,98 @@ namespace Easy
|
||||||
public:
|
public:
|
||||||
using Entity::Entity;
|
using Entity::Entity;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Metadata for attachments.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
class Meta : public Entity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using Entity::Entity;
|
||||||
|
|
||||||
|
virtual bool valid() const override;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Aspect of original image.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
double aspect() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Aspect of preview image.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
double aspect_small() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the bitrate of a video.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
uint64_t bitrate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the duration of a video in seconds.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
const std::chrono::duration<double> duration() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the framerate of a video in frames per second.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
double frame_rate() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the height of the original image.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
uint64_t height() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the height of the preview image.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
uint64_t height_small() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the size of the original image.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
const string size() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the size of the preview image.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
const string size_small() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the width of the original image.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
uint64_t width() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the width of the preview image
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
uint64_t width_small() const;
|
||||||
|
};
|
||||||
|
|
||||||
virtual bool valid() const override;
|
virtual bool valid() const override;
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Aspect of original image
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
double aspect() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Aspect of preview image
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
double aspect_small() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the bitrate of a video
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
uint64_t bitrate() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the image description
|
* @brief Returns the image description
|
||||||
*
|
*
|
||||||
|
@ -85,13 +154,6 @@ namespace Easy
|
||||||
*/
|
*/
|
||||||
Attachment description(const string &description);
|
Attachment description(const string &description);
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the duration of a video in seconds
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
const std::chrono::duration<double> duration() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Gets file to upload
|
* @brief Gets file to upload
|
||||||
*
|
*
|
||||||
|
@ -126,27 +188,6 @@ namespace Easy
|
||||||
*/
|
*/
|
||||||
Attachment focus(const std::array<double, 2> &focus);
|
Attachment focus(const std::array<double, 2> &focus);
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the framerate of a video in frames per second
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
double framerate() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the height of the original image
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
uint64_t height() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the height of the preview image
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
uint64_t height_small() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the ID of the attachment
|
* @brief Returns the ID of the attachment
|
||||||
*
|
*
|
||||||
|
@ -154,6 +195,13 @@ namespace Easy
|
||||||
*/
|
*/
|
||||||
const string id() const;
|
const string id() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns metadata about the attachment.
|
||||||
|
*
|
||||||
|
* @since 0.106.0
|
||||||
|
*/
|
||||||
|
const Meta meta() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the URL of the preview image
|
* @brief Returns the URL of the preview image
|
||||||
*
|
*
|
||||||
|
@ -168,20 +216,6 @@ namespace Easy
|
||||||
*/
|
*/
|
||||||
const string remote_url() const;
|
const string remote_url() const;
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the size of the original image
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
const string size() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the size of the preview image
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
const string size_small() const;
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns shorter URL for the image
|
* @brief Returns shorter URL for the image
|
||||||
*
|
*
|
||||||
|
@ -202,22 +236,6 @@ namespace Easy
|
||||||
* @since before 0.11.0
|
* @since before 0.11.0
|
||||||
*/
|
*/
|
||||||
const string url() const;
|
const string url() const;
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the width of the original image
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
uint64_t width() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the width of the preview image
|
|
||||||
*
|
|
||||||
* @since before 0.11.0
|
|
||||||
*/
|
|
||||||
uint64_t width_small() const;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue